Skip to content

Commit 7eb2b15

Browse files
committed
feat(scene): Added OnSceneSwitched event
1 parent 68dba4a commit 7eb2b15

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

MLAPI/NetworkingManagerComponents/Core/NetworkSceneManager.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ namespace MLAPI.Components
1515
/// </summary>
1616
public static class NetworkSceneManager
1717
{
18+
/// <summary>
19+
/// Delegate for when the scene has been switched
20+
/// </summary>
21+
public delegate void SceneSwitchedDelegate();
22+
/// <summary>
23+
/// Event that is invoked when the scene is switched
24+
/// </summary>
25+
public static event SceneSwitchedDelegate OnSceneSwitched;
26+
1827
internal static readonly HashSet<string> registeredSceneNames = new HashSet<string>();
1928
internal static readonly Dictionary<string, uint> sceneNameToIndex = new Dictionary<string, uint>();
2029
internal static readonly Dictionary<uint, string> sceneIndexToString = new Dictionary<uint, string>();
@@ -245,6 +254,11 @@ private static void OnSceneUnloadServer(AsyncOperation operation, Guid switchSce
245254
}
246255

247256
isSwitching = false;
257+
258+
if (OnSceneSwitched != null)
259+
{
260+
OnSceneSwitched();
261+
}
248262
}
249263

250264
private static void OnSceneUnloadClient(AsyncOperation operation, Guid switchSceneGuid, Stream objectStream)
@@ -307,6 +321,11 @@ private static void OnSceneUnloadClient(AsyncOperation operation, Guid switchSce
307321
}
308322

309323
isSwitching = false;
324+
325+
if (OnSceneSwitched != null)
326+
{
327+
OnSceneSwitched();
328+
}
310329
}
311330

312331
internal static bool HasSceneMismatch(uint sceneIndex)

0 commit comments

Comments
 (0)