I have a simple setup where I Host and Join in two editor instances (thanks to ParrelSync).
Every time I make a script change, recompile, start a host and connect the client on the other instance, the RPC calls fail with a warning message on the server side:
[Netcode] Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s).
I then exit playmode in both editors, and do the exact same thing again, and then it is working. I’ve gotten into the habit of start host, join client, exit playmode, start host, join client and THEN do my tests.
I did some digging and figured out that the behaviour is “fixed” by enabling Reload Scene under Enter Play Mode Settings (I used to have scene reload disabled):
What could be causing such a behaviour?
I’m aware of domain reload issues, specifically with statics and events. But I didn’t expect t̶h̶e̶ ̶s̶p̶a̶n̶i̶s̶h̶ ̶i̶n̶q̶u̶i̶s̶i̶t̶i̶o̶n̶ Reload Scene to be an issue in this case.
Here’s the scene hierarchy:
NetworkManager (in Bootstrap) has one Player prefab and connection approval enabled (currently always approves and passes the player name in the payload). I use Unity Transport, and connection info (address, port) are provided via the StartMenu GUI.
QuickStartMenu is just a GUI that eventually calls StartHost/Client.
DataTransfer is in-scene placed network object which fails to send/receive RPC calls.
It has a NetworkFileTransfer (MonoBehaviour) and three NetworkBehaviour (NetworkDataTransfer*) and the NetworkObject.
ServerRPC calls are set to RequireOwnership = false
I would post code but I wouldn’t even know where to begin looking for the root cause of an issue like this. Like I said, it always works the second (and third etc) time entering playmode but never the first time AFTER a recompile / assembly reload when Reload Scene is unchecked.
I had this issue both in 2022.2.9 (beta) and now I’m in 2020.3.40 with the same behaviour.
Any ideas? I just like to understand the issue, I don’t mind having Reload Scene enabled.