I’d like to have a NetworkBehaviour singleton to manage general networked information. However I’m not sure the proper way to do this.
If I have the singleton as a scene object then it doesn’t ever “spawn” once the server starts (at least in the .exe… in the editor it works fine… unsure why editor and build file give different results). In addition it never “spawns” on the client even if it spawns on the server. The object is there… it’s just disabled/grayed out (not “spawned”). And if I check the server and the NetworkBehaviour is being watched by client… so I’m unsure why client never got the “spawn” message.
If I manually Instantiate/Spawn the singleton during NetworkServer.OnServerStart then it spawns on the server, but not on client. It seems buggy. If I manually add a few second delay then things seem to work.
Since the object is persistent you use DontDestroyOnLoad. But when entering a scene this additional spawned object that is not part of that scene seems to make UNET count mismatch errors.
CRC Local Dump Inventory : 0
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
Spawn scene object not found for 9
UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
Also not sure how to handle the singleton when the game quits and everybody returns to main menu and network connection is lost.
Has anybody had success making a NetworkBehaviour singleton? Any tips? Thanks in advance.