@@ -47,7 +47,15 @@ public static void SwitchScene(string sceneName)
4747 isSwitching = true ;
4848 lastScene = SceneManager . GetActiveScene ( ) ;
4949 AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Additive ) ;
50+ #if ! UNITY_5
5051 sceneLoad . completed += OnSceneLoaded ;
52+ #else
53+ NetworkingManager . singleton . StartCoroutine ( NetworkingManager . singleton . WaitForSceneSwitch ( sceneLoad , ( ) =>
54+ {
55+ //This block runs when scene switch is done.
56+ OnSceneLoaded ( sceneLoad ) ;
57+ } ) ) ;
58+ #endif
5159 using ( MemoryStream stream = new MemoryStream ( 4 ) )
5260 {
5361 using ( BinaryWriter writer = new BinaryWriter ( stream ) )
@@ -72,7 +80,15 @@ internal static void OnSceneSwitch(uint sceneIndex)
7280 }
7381 lastScene = SceneManager . GetActiveScene ( ) ;
7482 AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneIndexToString [ sceneIndex ] , LoadSceneMode . Additive ) ;
83+ #if ! UNITY_5
7584 sceneLoad . completed += OnSceneLoaded ;
85+ #else
86+ NetworkingManager . singleton . StartCoroutine ( NetworkingManager . singleton . WaitForSceneSwitch ( sceneLoad , ( ) =>
87+ {
88+ //This block runs when scene switch is done.
89+ OnSceneLoaded ( sceneLoad ) ;
90+ } ) ) ;
91+ #endif
7692 }
7793
7894 private static void OnSceneLoaded ( AsyncOperation operation )
@@ -85,7 +101,15 @@ private static void OnSceneLoaded(AsyncOperation operation)
85101 SceneManager . MoveGameObjectToScene ( objectsToKeep [ i ] . gameObject , nextScene ) ;
86102 }
87103 AsyncOperation sceneLoad = SceneManager . UnloadSceneAsync ( lastScene ) ;
104+ #if ! UNITY_5
88105 sceneLoad . completed += OnSceneUnload ;
106+ #else
107+ NetworkingManager . singleton . StartCoroutine ( NetworkingManager . singleton . WaitForSceneSwitch ( sceneLoad , ( ) =>
108+ {
109+ //This block runs when scene switch is done.
110+ OnSceneUnload ( sceneLoad ) ;
111+ } ) ) ;
112+ #endif
89113 }
90114
91115 private static void OnSceneUnload ( AsyncOperation operation )
0 commit comments