-
Notifications
You must be signed in to change notification settings - Fork 463
Closed
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at UnityStatus - Issue is tracked internally at Unitytype:bugBug ReportBug Report
Description
Description
When you try to unload a scene with the NetworkSceneManager that is not loaded using the NetworkSceneManger, then the status SceneEventProgressStatus.InternalNetcodeError is returned, with an error message because of the following code:
if (!ScenesLoaded.ContainsKey(sceneHandle))
{
Debug.LogError($"{nameof(UnloadScene)} internal error! {sceneName} with handle {scene.handle} is not within the internal scenes loaded dictionary!");
return SceneEventProgressStatus.InternalNetcodeError;
}
This makes it so that any subsequent scene loads or unloads will have the status SceneEventProgressStatus.SceneEventInProgress and will fail to load/unload.
Reproduce Steps
- Open up a scene in Unity (Scene1)
- Enter play mode and start a server
- Load in a different scene (Scene2) using the NetworkSceneManager and set that scene as active when it's loaded.
- Try to unload Scene1 using the NetworkSceneManager
- Try to load in another scene (Scene3) using the NetworkSceneManager.
Actual Outcome
I receive a status SceneEventProgressStatus.SceneEventInProgress when loading in Scene3.
Expected Outcome
I receive a status SceneEventProgressStatus.Started when loading in Scene3.
Possible solutions
- Right now we are resetting the field
m_IsSceneEventActiveusing reflection when UnloadScene returns SceneEventProgressStatus.InternalNetcodeError. This could be moved toNetworkSceneManager.UnloadScene.
var isSceneEventActiveField = typeof(NetworkSceneManager).GetField("m_IsSceneEventActive", BindingFlags.Instance | BindingFlags.NonPublic);
isSceneEventActiveField?.SetValue(NetworkManager.Singleton.SceneManager, false);
- If we could check if the
ScenesLoadedlist insideNetworkSceneManagercontains the scene we are trying to unload by exposingScenesLoaded, we can predict if this issue will occur and just not callNetworkSceneManager.UnloadScene.
Environment
- OS: Windows
- Unity Version: 2022.3
- Netcode Version: 1.6.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority:highThis issue has high priority and we are focusing to resolve itThis issue has high priority and we are focusing to resolve itstat:importedStatus - Issue is tracked internally at UnityStatus - Issue is tracked internally at Unitytype:bugBug ReportBug Report