FishNet icon indicating copy to clipboard operation
FishNet copied to clipboard

(Version 2.4.5) Network Object components added automatically to prefabs seem to have problems with storing their asset path hash

Open sparkaha opened this issue 3 years ago • 2 comments

I changed the class of a component that was present on multiple prefabs from MonoBehavior to NetworkBehaviour. This automatically added NetworkObject components to the root of the prefabs as expected.

When calculating the asset path hash for the new components via the menu, everything looked fine (I used the debugger to check the hashes and they looked valid).

But when I started the game, FishNet.Managing.Object.DefaultPrefabObjects.Sort() logged the error "AssetPathHash is not set for GameObject XYZ" and "One or more NetworkObject prefabs did not have their AssetPathHash set. This usually occurs when a prefab cannot be saved. Check the specified prefabs for missing scripts or serialization errors and correct them, then use Fish-Networking -> Refresh Default Prefabs."

I checked the prefabs and did not find any errors in the set up.

I was able to work around the problem by going through the prefabs with the automatically added NetworkObject component and manually delete and re-add the component (which triggered unity to save the prefab again). After this the error disappeared.

(I also tried out restarting unity before but that did not help).

sparkaha avatar Oct 06 '22 15:10 sparkaha

I'm fairly certain this is a Unity bug. I'm going to close this out in a week. Let me know if you have any further issues please.

FirstGearGames avatar Oct 09 '22 15:10 FirstGearGames

Sorry, I did not think about that. I know that saving changes to prefabs properly can be a pain, so I jumped to conclusions a bit.

sparkaha avatar Oct 10 '22 09:10 sparkaha