In NGO version 2.11.1, a NullReferenceException is thrown in NetworkConnectionManager.cs at line 975 when PlayerPrefab is not assigned in the inspector.
Current code:
varidHashToSpawn=playerPrefabHash??NetworkManager.NetworkConfig.PlayerPrefab?.GetComponent<NetworkObject>()?.GlobalObjectIdHash;
Changing the code to the following fixes the issue:
varidHashToSpawn=playerPrefabHash;varplayerPrefab=NetworkManager.NetworkConfig.PlayerPrefab;if(idHashToSpawn==null&&playerPrefab!=null&&playerPrefab.TryGetComponent<NetworkObject>(outvarplayerNetworkObject))idHashToSpawn=playerNetworkObject.GlobalObjectIdHash;
After this change, everything works correctly even when PlayerPrefab is not assigned.
The exception occurs after calling:
NetworkManager.StartHost();
while using SinglePlayerTransport.
Environment:
- NGO version:
2.11.1 - Transport:
SinglePlayerTransport - Unity version: 6000.3.11.f1
In NGO version
2.11.1, aNullReferenceExceptionis thrown inNetworkConnectionManager.csat line975whenPlayerPrefabis not assigned in the inspector.Current code:
Changing the code to the following fixes the issue:
After this change, everything works correctly even when
PlayerPrefabis not assigned.The exception occurs after calling:
while using
SinglePlayerTransport.Environment:
2.11.1SinglePlayerTransport