com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Broadcast UnloadComplete SceneEvent after m_IsSceneEventActive is set to false

Open danielchipman opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe. In OnSceneUnloaded in NetworkSceneManager.cs, m_IsSceneEventActive doesn't get reset to false until after OnSceneEvent is invoked. This causes scene operation requests such as LoadScene or UnloadScene to be rejected with SceneEventProgressStatus.SceneEventInProgress in OnSceneEvent listeners when sceneEvent.SceneEventType == SceneEventType.UnloadComplete. This requires users to needlessly defer chained scene operations by a frame.

Describe the solution you'd like Would recommend moving the OnSceneEvent invocation in OnSceneUnloaded until after m_IsSceneEventActive is set to false.

Describe alternatives you've considered Another acceptable solution would be to add an event to NetworkSceneManager that is invoked when the system is ready to accept new scene operations.

Additional context This feels like a bug to me, especially since the behavior for OnServerLoadedScene sends the event after clearing the OnServerLoadedScene state as expected. The ordering for OnSceneUnloaded doesn't just feel erroneous for an end user, it's also inconsistent.

danielchipman avatar Mar 24 '22 00:03 danielchipman