UNET Network Documentation on and therefore execution order for ClientScene.RegisterPrefab is wrong
1. What happened
I was trying to make use of the custom callbacks for spawning Prefabs using ClientScene.RegisterPrefab with delegates. This however turned out to be hard to get right with the HLAPI.
I added a screenshot to clarify the issue. Since the project is quite large and hard to get running I can't isolate the problem right now but can describe it.
- I'm using a basic NetworkManager with online offline scene configuration
- In the online scene, there's a scene gameobject with a NetworkBehaviour component calling the desired RegisterPrefab call in OnStartClient (as provided in https://docs.unity3d.com/ScriptReference/Networking.ClientScene.RegisterPrefab.html
I'm running a standalone instance on the same computer as my client connecting from the Unity editor.
On connecting the client, the following happens, as shown in the screenshot.
The ClientScene ins readied (green) and the call from the server to instantiate the prefab is executed (red) before OnStartClient is even called to register the prefab (2. green).
This is completely unexpected and leaves me thinking that the only place one can EVER use these callbacks is either before any networking occured (meaning NOT on any NetworkBehaviour, before a connection is established), or in Awake.
Is that assumption right, or why is the documentation wrong about how to use it?
License type: Pro