@@ -23,9 +23,17 @@ public static class NetworkSceneManager
23
23
/// </summary>
24
24
public delegate void SceneSwitchedDelegate ( ) ;
25
25
/// <summary>
26
+ /// Delegate for when a scene switch has been initiated
27
+ /// </summary>
28
+ public delegate void SceneSwitchStartedDelegate ( AsyncOperation operation ) ;
29
+ /// <summary>
26
30
/// Event that is invoked when the scene is switched
27
31
/// </summary>
28
32
public static event SceneSwitchedDelegate OnSceneSwitched ;
33
+ /// <summary>
34
+ /// Event that is invoked when a local scene switch has started
35
+ /// </summary>
36
+ public static event SceneSwitchStartedDelegate OnSceneSwitchStarted ;
29
37
30
38
internal static readonly HashSet < string > registeredSceneNames = new HashSet < string > ( ) ;
31
39
internal static readonly Dictionary < string , uint > sceneNameToIndex = new Dictionary < string , uint > ( ) ;
@@ -105,12 +113,18 @@ public static SceneSwitchProgress SwitchScene(string sceneName)
105
113
106
114
// Switch scene
107
115
AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
116
+
108
117
nextSceneName = sceneName ;
109
118
110
119
sceneLoad . completed += ( AsyncOperation asyncOp2 ) => { OnSceneLoaded ( switchSceneProgress . guid , null ) ; } ;
111
120
112
121
switchSceneProgress . SetSceneLoadOperation ( sceneLoad ) ;
113
122
123
+ if ( OnSceneSwitchStarted != null )
124
+ {
125
+ OnSceneSwitchStarted ( sceneLoad ) ;
126
+ }
127
+
114
128
return switchSceneProgress ;
115
129
}
116
130
@@ -137,12 +151,18 @@ internal static void OnSceneSwitch(uint sceneIndex, Guid switchSceneGuid, Stream
137
151
string sceneName = sceneIndexToString [ sceneIndex ] ;
138
152
139
153
AsyncOperation sceneLoad = SceneManager . LoadSceneAsync ( sceneName , LoadSceneMode . Single ) ;
154
+
140
155
nextSceneName = sceneName ;
141
156
142
157
sceneLoad . completed += ( AsyncOperation asyncOp2 ) =>
143
158
{
144
159
OnSceneLoaded ( switchSceneGuid , objectStream ) ;
145
160
} ;
161
+
162
+ if ( OnSceneSwitchStarted != null )
163
+ {
164
+ OnSceneSwitchStarted ( sceneLoad ) ;
165
+ }
146
166
}
147
167
148
168
internal static void OnFirstSceneSwitchSync ( uint sceneIndex , Guid switchSceneGuid )
0 commit comments