Description
Description
I call StartServer() when the NetworkManager.OnSingletonReady event is raised (yes, the internal event).
This immediately throws the following exception:
Exception: Allowed types is not equal to the number of message type indices! Allowed Count: 0 | Index Count: 25
Unity.Netcode.ILPPMessageProvider.GetMessages () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/ILPPMessageProvider.cs:69)
Unity.Netcode.NetworkMessageManager..ctor (Unity.Netcode.INetworkMessageSender sender, System.Object owner, Unity.Netcode.INetworkMessageProvider provider) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/NetworkMessageManager.cs:170)
Unity.Netcode.NetworkManager.Initialize (System.Boolean server) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1123)
Unity.Netcode.NetworkManager.StartServer () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:1243)
CodeSmile.BetterNetcode.Network.NetworkState.StartServer () (at Assets/Scripts/Runtime/Network/NetworkState.cs:67)
CodeSmile.BetterNetcode.Network.NetworkState.<Awake>b__5_0 (CodeSmile.BetterNetcode.Network.NetworkState+StateChangedEventArgs args) (at Assets/Scripts/Runtime/Network/NetworkState.cs:50)
CodeSmile.BetterNetcode.Network.NetworkState.ChangeState (CodeSmile.BetterNetcode.Network.NetworkState+State newState) (at Assets/Scripts/Runtime/Network/NetworkState.cs:87)
CodeSmile.BetterNetcode.Network.NetworkState.OnNetworkManagerSingletonReady () (at Assets/Scripts/Runtime/Network/NetworkState.cs:58)
CodeSmile.Netcode.Extensions.NetworkManagerExt.InvokeSingletonReadyCallbacksOnce () (at ./Packages/de.codesmile.netcode/Runtime/Extensions/NetworkManagerExt.cs:81)
Unity.Netcode.NetworkManager.SetSingleton () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:957)
Unity.Netcode.NetworkManager.OnEnable () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:979)
This issue occurs in Netcode 2.0.0-pre.2 but not in 1.9.1 in Unity 6000.0.11f1.
The issue does not occur when I delay calling StartServer() from Start() rather than directly from the OnSingletonReady event. The NetworkState component from which I call StartServer() is attached to the NetworkManager object.
It seems the NetworkManager singleton isn't actually "fully ready" when the OnSingletonReady event gets raised. Although this is an internal event, I wanted to flag this because a) it's nevertheless unexpected and b) this behaviour has changed between NGO 1.9 and 2.0. It may indicate a possible order of initialization issue in the NetworkMessageManager subsystem.