@@ -47,7 +47,15 @@ public static void SwitchScene(string sceneName)
47
47
isSwitching = true ;
48
48
lastScene = SceneManager . GetActiveScene ( ) ;
49
49
AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Additive ) ;
50
+ #if ! UNITY_5
50
51
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
51
59
using ( MemoryStream stream = new MemoryStream ( 4 ) )
52
60
{
53
61
using ( BinaryWriter writer = new BinaryWriter ( stream ) )
@@ -72,7 +80,15 @@ internal static void OnSceneSwitch(uint sceneIndex)
72
80
}
73
81
lastScene = SceneManager . GetActiveScene ( ) ;
74
82
AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneIndexToString [ sceneIndex ] , LoadSceneMode . Additive ) ;
83
+ #if ! UNITY_5
75
84
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
76
92
}
77
93
78
94
private static void OnSceneLoaded ( AsyncOperation operation )
@@ -85,7 +101,15 @@ private static void OnSceneLoaded(AsyncOperation operation)
85
101
SceneManager . MoveGameObjectToScene ( objectsToKeep [ i ] . gameObject , nextScene ) ;
86
102
}
87
103
AsyncOperation sceneLoad = SceneManager . UnloadSceneAsync ( lastScene ) ;
104
+ #if ! UNITY_5
88
105
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
89
113
}
90
114
91
115
private static void OnSceneUnload ( AsyncOperation operation )
0 commit comments