@@ -724,6 +724,14 @@ internal string ScenePathFromHash(uint sceneHash)
724724 }
725725 else
726726 {
727+ // In the event there is no scene associated with the scene event then just return "No Scene"
728+ // This can happen during unit tests when clients first connect and the only scene loaded is the
729+ // unit test scene (which is ignored by default) that results in a scene event that has no associated
730+ // scene. Under this specific special case, we just return "No Scene".
731+ if ( sceneHash == 0 )
732+ {
733+ return "No Scene" ;
734+ }
727735 throw new Exception ( $ "Scene Hash { sceneHash } does not exist in the { nameof ( HashToBuildIndex ) } table! Verify that all scenes requiring" +
728736 $ " server to client synchronization are in the scenes in build list.") ;
729737 }
@@ -1198,7 +1206,7 @@ public SceneEventProgressStatus UnloadScene(Scene scene)
11981206 sceneEventProgress . OnSceneEventCompleted = OnSceneUnloaded ;
11991207 var sceneUnload = SceneManagerHandler . UnloadSceneAsync ( scene , sceneEventProgress ) ;
12001208 // Notify local server that a scene is going to be unloaded
1201- InvokeSceneEvents ( NetworkManager . ServerClientId , sceneEventData ) ;
1209+ InvokeSceneEvents ( NetworkManager . ServerClientId , sceneEventData , sceneUnload ) ;
12021210
12031211 //Return the status
12041212 return sceneEventProgress . Status ;
@@ -1254,8 +1262,11 @@ private void OnClientUnloadScene(uint sceneEventId)
12541262 throw new Exception ( $ "Failed to remove server scene handle ({ sceneEventData . SceneHandle } ) or client scene handle({ sceneHandle } )! Happened during scene unload for { sceneName } .") ;
12551263 }
12561264
1265+ // The only scenes unloaded are scenes that were additively loaded
1266+ sceneEventData . LoadSceneMode = LoadSceneMode . Additive ;
1267+
12571268 // Notify the local client that a scene is going to be unloaded
1258- InvokeSceneEvents ( NetworkManager . LocalClientId , sceneEventData ) ;
1269+ InvokeSceneEvents ( NetworkManager . LocalClientId , sceneEventData , sceneUnload ) ;
12591270 }
12601271
12611272 /// <summary>
@@ -1933,7 +1944,7 @@ private void ClientLoadedSynchronization(uint sceneEventId)
19331944 EndSceneEvent ( responseSceneEventData . SceneEventId ) ;
19341945
19351946 // Send notification to local client that the scene has finished loading
1936- InvokeSceneEvents ( NetworkManager . LocalClientId , responseSceneEventData ) ;
1947+ InvokeSceneEvents ( NetworkManager . LocalClientId , responseSceneEventData , scene : nextScene ) ;
19371948
19381949 // Check to see if we still have scenes to load and synchronize with
19391950 HandleClientSceneEvent ( sceneEventId ) ;
0 commit comments