Scene objects are not reset after disconnecting
Describe the bug When disconnecting & reconnecting to a server as a client without reloading the scene, the state of scene network objects is not reset. This might lead to syncvar hooks not firing since the syncvar is still the same. I'm not sure if this qualifies as a bug or is worth fixing, just something I stumbled upon
How to reproduce the issue, step by step Add SyncVar to networked scene object
[SyncVar(hook = nameof(BlaChanged))]
public string bla = 0;
void BlaChanged(string old, string bla)
{
Debug.LogError($"{gameObject.name} - Changed from {old} to {bla}");
}
- Leave at default value, connect client, no SyncVar hook fires ✅
- Disconnect client, change to something different, reconnect client without restarting, SyncVar hook fires ✅
- Disconnect client, change back to default value, reconnect client without restarting, SyncVar hook fires with "default" value ❓
Expected behavior It might be more intuitive to reset scene objects to their default state when disconnecting
Screenshots left side: host, inspector: networked scene object, right side: client https://share.dl.je/2021/03/2021-03-24_00-45-33_qXvCbPvObp.mp4
Expected behavior It might be more intuitive to reset scene objects to their default state when disconnecting
I don't think we should be silently doing this. If you want the scene restored, reload it, or have offline and online scenes set up and assigned so you get a new Network Manager in the offline scene to ensure a clean restart.