Hey everyone,
I am working on a multiplayer game where I want to restart the current level.
Therefore, I use:
NetworkManager.singleton.ServerChangeScene(SceneManager.GetActiveScene().name);
The server (not host without any connected clients) reloads the scene, but the console shows the following code multiple times (for netId 1 to 55) in a loop:
Found ‘null’ entry in spawned list for netId=1. Please call NetworkServer.Destroy to destroy networked objects. Don’t use GameObject.Destroy.
UnityEngine.Logger:Log(LogType, Object)
Mirror.ILoggerExtensions:LogWarning(ILogger, Object) (at Assets/Mirror/Runtime/Logging/LogFactory.cs:93)
Mirror.NetworkServer:Update() (at Assets/Mirror/Runtime/NetworkServer.cs:470)
Mirror.NetworkManager:LateUpdate() (at Assets/Mirror/Runtime/NetworkManager.cs:272)
Additionally, all objects in the reloaded scene containing a NetworkIdentity Component do not get spawned.
I already tried to destroy all objects before loading the scene without any difference: Interestingly, the debug print in the following code outputs only 6 objects instead of 55. But the reloaded scene’s error still reports 55 missing objects.
public void RestartExperience() {
// Found 'null' entry in spawned list for netId=1. Please call NetworkServer.Destroy
NetworkIdentity[] netIdents = FindObjectsOfType<NetworkIdentity>();
print($"Amount of objects found: {netIdents.Length}");
for (int i = 0; i < netIdents.Length; i++) {
NetworkServer.Destroy(netIdents[i].gameObject);
}
NetworkManager.singleton.ServerChangeScene(SceneManager.GetActiveScene().name);
}