#Static instance become null while another client disconnected.
11 messages · Page 1 of 1 (latest)
Not unexpected...when client disconnects, all networkbehaviours are destroyed, all runtime spawned networked objects destroyed, making your static ref null.
Okay, i must miss something
Thanks
wait.i mean,there are host,client A and client B.they are all connected.when client B disconnected, _instance in client A become null.will the disconnection of client B affect local static variable of client A?
No, but the more I look at your code the more I realize this is over-centralization. Much of this should be SyncVars and hooks in a component on the player object, not a separate object for each client besides the player object.
OK,I try another way
Look at the Basic example that comes with Mirror. Same principal. Each player object has a component that feeds the shared scene UI. UI fragment is part of it, but SyncVar for Ready, char choice, etc. with hooks can feed that too.
I want to decentralize the player information so that it can behave differently in different scenes. However, I generated a corresponding CustomRoomAnnouncer for each player in one scene, which seems like too much. Now I'm trying to generate one CustomRoomAnnouncer per scene, so that the player's data in that scene is managed by a singleton on that server, rather than having one singleton per player.
Yes, you are right, I should use more such like SyncVar SyncList SyncDictionary.
I changed the code. Using SyncVar is indeed much cleaner.
https://pastie.io/ifqcox.cs