-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathNetworkSceneManager.cs
More file actions
2085 lines (1843 loc) · 104 KB
/
NetworkSceneManager.cs
File metadata and controls
2085 lines (1843 loc) · 104 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System.Collections.Generic;
using System;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Unity.Netcode
{
/// <summary>
/// Used for local notifications of various scene events. The <see cref="NetworkSceneManager.OnSceneEvent"/> of
/// delegate type <see cref="NetworkSceneManager.SceneEventDelegate"/> uses this class to provide
/// scene event status.<br/>
/// <em>Note: This is only when <see cref="NetworkConfig.EnableSceneManagement"/> is enabled.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// See also: <br/>
/// <seealso cref="SceneEventType"/>
/// </summary>
public class SceneEvent
{
/// <summary>
/// The <see cref="UnityEngine.AsyncOperation"/> returned by <see cref="SceneManager"/><BR/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.Load"/></term></item>
/// <item><term><see cref="SceneEventType.Unload"/></term></item>
/// </list>
/// </summary>
public AsyncOperation AsyncOperation;
/// <summary>
/// Will always be set to the current <see cref="Netcode.SceneEventType"/>
/// </summary>
public SceneEventType SceneEventType;
/// <summary>
/// If applicable, this reflects the type of scene loading or unloading that is occurring.<BR/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.Load"/></term></item>
/// <item><term><see cref="SceneEventType.Unload"/></term></item>
/// <item><term><see cref="SceneEventType.LoadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.LoadEventCompleted"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadEventCompleted"/></term></item>
/// </list>
/// </summary>
public LoadSceneMode LoadSceneMode;
/// <summary>
/// This will be set to the scene name that the event pertains to.<BR/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.Load"/></term></item>
/// <item><term><see cref="SceneEventType.Unload"/></term></item>
/// <item><term><see cref="SceneEventType.LoadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.LoadEventCompleted"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadEventCompleted"/></term></item>
/// </list>
/// </summary>
public string SceneName;
/// <summary>
/// When a scene is loaded, the Scene structure is returned.<BR/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.LoadComplete"/></term></item>
/// </list>
/// </summary>
public Scene Scene;
/// <summary>
/// The client identifier can vary depending upon the following conditions: <br/>
/// <list type="number">
/// <item><term><see cref="Netcode.SceneEventType"/>s that always set the <see cref="ClientId"/>
/// to the local client identifier, are initiated (and processed locally) by the
/// server-host, and sent to all clients to be processed.<br/>
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.Load"/></term></item>
/// <item><term><see cref="SceneEventType.Unload"/></term></item>
/// <item><term><see cref="SceneEventType.Synchronize"/></term></item>
/// <item><term><see cref="SceneEventType.ReSynchronize"/></term></item>
/// </list>
/// </term></item>
/// <item><term>Events that always set the <see cref="ClientId"/> to the local client identifier,
/// are initiated (and processed locally) by a client or server-host, and if initiated
/// by a client will always be sent to and processed on the server-host:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.LoadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadComplete"/></term></item>
/// <item><term><see cref="SceneEventType.SynchronizeComplete"/></term></item>
/// </list>
/// </term></item>
/// <item><term>
/// Events that always set the <see cref="ClientId"/> to the ServerId:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.LoadEventCompleted"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadEventCompleted"/></term></item>
/// </list>
/// </term></item>
/// </list>
/// </summary>
public ulong ClientId;
/// <summary>
/// List of clients that completed a loading or unloading event.<br/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.LoadEventCompleted"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadEventCompleted"/></term></item>
/// </list>
/// </summary>
public List<ulong> ClientsThatCompleted;
/// <summary>
/// List of clients that timed out during a loading or unloading event.<br/>
/// This is set for the following <see cref="Netcode.SceneEventType"/>s:
/// <list type="bullet">
/// <item><term><see cref="SceneEventType.LoadEventCompleted"/></term></item>
/// <item><term><see cref="SceneEventType.UnloadEventCompleted"/></term></item>
/// </list>
/// </summary>
public List<ulong> ClientsThatTimedOut;
}
/// <summary>
/// Main class for managing network scenes when <see cref="NetworkConfig.EnableSceneManagement"/> is enabled.
/// Uses the <see cref="SceneEventMessage"/> message to communicate <see cref="SceneEventData"/> between the server and client(s)
/// </summary>
public class NetworkSceneManager : IDisposable
{
private const NetworkDelivery k_DeliveryType = NetworkDelivery.ReliableFragmentedSequenced;
internal const int InvalidSceneNameOrPath = -1;
// Used to be able to turn re-synchronization off
internal static bool DisableReSynchronization;
/// <summary>
/// Used to detect if a scene event is underway
/// Only 1 scene event can occur on the server at a time for now.
/// </summary>
private bool m_IsSceneEventActive = false;
/// <summary>
/// The delegate callback definition for scene event notifications.<br/>
/// See also: <br/>
/// <seealso cref="SceneEvent"/><br/>
/// <seealso cref="SceneEventData"/>
/// </summary>
/// <param name="sceneEvent"></param>
public delegate void SceneEventDelegate(SceneEvent sceneEvent);
/// <summary>
/// Subscribe to this event to receive all <see cref="SceneEventType"/> notifications.<br/>
/// For more details review over <see cref="SceneEvent"/> and <see cref="SceneEventType"/>.<br/>
/// <b>Alternate Single Event Type Notification Registration Options</b><br/>
/// To receive only a specific event type notification or a limited set of notifications you can alternately subscribe to
/// each notification type individually via the following events:<br/>
/// <list type="bullet">
/// <item><term><see cref="OnLoad"/> Invoked only when a <see cref="SceneEventType.Load"/> event is being processed</term></item>
/// <item><term><see cref="OnUnload"/> Invoked only when an <see cref="SceneEventType.Unload"/> event is being processed</term></item>
/// <item><term><see cref="OnSynchronize"/> Invoked only when a <see cref="SceneEventType.Synchronize"/> event is being processed</term></item>
/// <item><term><see cref="OnLoadEventCompleted"/> Invoked only when a <see cref="SceneEventType.LoadEventCompleted"/> event is being processed</term></item>
/// <item><term><see cref="OnUnloadEventCompleted"/> Invoked only when an <see cref="SceneEventType.UnloadEventCompleted"/> event is being processed</term></item>
/// <item><term><see cref="OnLoadComplete"/> Invoked only when a <see cref="SceneEventType.LoadComplete"/> event is being processed</term></item>
/// <item><term><see cref="OnUnloadComplete"/> Invoked only when an <see cref="SceneEventType.UnloadComplete"/> event is being processed</term></item>
/// <item><term><see cref="OnSynchronizeComplete"/> Invoked only when a <see cref="SceneEventType.SynchronizeComplete"/> event is being processed</term></item>
/// </list>
/// <em>Note: Do not start new scene events within NetworkSceneManager scene event notification callbacks.</em><br/>
/// </summary>
public event SceneEventDelegate OnSceneEvent;
/// <summary>
/// Delegate declaration for the OnLoad event.<br/>
/// See also: <br/>
/// <seealso cref="SceneEventType.Load"/>for more information
/// </summary>
/// <param name="clientId">the client that is processing this event (the server will receive all of these events for every client and itself)</param>
/// <param name="sceneName">name of the scene being processed</param>
/// <param name="loadSceneMode">the LoadSceneMode mode for the scene being loaded</param>
/// <param name="asyncOperation">the associated <see cref="AsyncOperation"/> that can be used for scene loading progress</param>
public delegate void OnLoadDelegateHandler(ulong clientId, string sceneName, LoadSceneMode loadSceneMode, AsyncOperation asyncOperation);
/// <summary>
/// Delegate declaration for the OnUnload event.<br/>
/// See also: <br/>
/// <seealso cref="SceneEventType.Unload"/> for more information
/// </summary>
/// <param name="clientId">the client that is processing this event (the server will receive all of these events for every client and itself)</param>
/// <param name="sceneName">name of the scene being processed</param>
/// <param name="asyncOperation">the associated <see cref="AsyncOperation"/> that can be used for scene unloading progress</param>
public delegate void OnUnloadDelegateHandler(ulong clientId, string sceneName, AsyncOperation asyncOperation);
/// <summary>
/// Delegate declaration for the OnSynchronize event.<br/>
/// See also: <br/>
/// <seealso cref="SceneEventType.Synchronize"/> for more information
/// </summary>
/// <param name="clientId">the client that is processing this event (the server will receive all of these events for every client and itself)</param>
public delegate void OnSynchronizeDelegateHandler(ulong clientId);
/// <summary>
/// Delegate declaration for the OnLoadEventCompleted and OnUnloadEventCompleted events.<br/>
/// See also:<br/>
/// <seealso cref="SceneEventType.LoadEventCompleted"/><br/>
/// <seealso cref="SceneEventType.UnloadEventCompleted"/>
/// </summary>
/// <param name="sceneName">scene pertaining to this event</param>
/// <param name="loadSceneMode"><see cref="LoadSceneMode"/> of the associated event completed</param>
/// <param name="clientsCompleted">the clients that completed the loading event</param>
/// <param name="clientsTimedOut">the clients (if any) that timed out during the loading event</param>
public delegate void OnEventCompletedDelegateHandler(string sceneName, LoadSceneMode loadSceneMode, List<ulong> clientsCompleted, List<ulong> clientsTimedOut);
/// <summary>
/// Delegate declaration for the OnLoadComplete event.<br/>
/// See also:<br/>
/// <seealso cref="SceneEventType.LoadComplete"/> for more information
/// </summary>
/// <param name="clientId">the client that is processing this event (the server will receive all of these events for every client and itself)</param>
/// <param name="sceneName">the scene name pertaining to this event</param>
/// <param name="loadSceneMode">the mode the scene was loaded in</param>
public delegate void OnLoadCompleteDelegateHandler(ulong clientId, string sceneName, LoadSceneMode loadSceneMode);
/// <summary>
/// Delegate declaration for the OnUnloadComplete event.<br/>
/// See also:<br/>
/// <seealso cref="SceneEventType.UnloadComplete"/> for more information
/// </summary>
/// <param name="clientId">the client that is processing this event (the server will receive all of these events for every client and itself)</param>
/// <param name="sceneName">the scene name pertaining to this event</param>
public delegate void OnUnloadCompleteDelegateHandler(ulong clientId, string sceneName);
/// <summary>
/// Delegate declaration for the OnSynchronizeComplete event.<br/>
/// See also:<br/>
/// <seealso cref="SceneEventType.SynchronizeComplete"/> for more information
/// </summary>
/// <param name="clientId">the client that completed this event</param>
public delegate void OnSynchronizeCompleteDelegateHandler(ulong clientId);
/// <summary>
/// Invoked when a <see cref="SceneEventType.Load"/> event is started by the server.<br/>
/// <em>Note: The server and connected client(s) will always receive this notification.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnLoadDelegateHandler OnLoad;
/// <summary>
/// Invoked when a <see cref="SceneEventType.Unload"/> event is started by the server.<br/>
/// <em>Note: The server and connected client(s) will always receive this notification.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnUnloadDelegateHandler OnUnload;
/// <summary>
/// Invoked when a <see cref="SceneEventType.Synchronize"/> event is started by the server
/// after a client is approved for connection in order to synchronize the client with the currently loaded
/// scenes and NetworkObjects. This event signifies the beginning of the synchronization event.<br/>
/// <em>Note: The server and connected client(s) will always receive this notification.
/// This event is generated on a per newly connected and approved client basis.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnSynchronizeDelegateHandler OnSynchronize;
/// <summary>
/// Invoked when a <see cref="SceneEventType.LoadEventCompleted"/> event is generated by the server.
/// This event signifies the end of an existing <see cref="SceneEventType.Load"/> event as it pertains
/// to all clients connected when the event was started. This event signifies that all clients (and server) have
/// finished the <see cref="SceneEventType.Load"/> event.<br/>
/// <em>Note: this is useful to know when all clients have loaded the same scene (single or additive mode)</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnEventCompletedDelegateHandler OnLoadEventCompleted;
/// <summary>
/// Invoked when a <see cref="SceneEventType.UnloadEventCompleted"/> event is generated by the server.
/// This event signifies the end of an existing <see cref="SceneEventType.Unload"/> event as it pertains
/// to all clients connected when the event was started. This event signifies that all clients (and server) have
/// finished the <see cref="SceneEventType.Unload"/> event.<br/>
/// <em>Note: this is useful to know when all clients have unloaded a specific scene. The <see cref="LoadSceneMode"/> will
/// always be <see cref="LoadSceneMode.Additive"/> for this event.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnEventCompletedDelegateHandler OnUnloadEventCompleted;
/// <summary>
/// Invoked when a <see cref="SceneEventType.LoadComplete"/> event is generated by a client or server.<br/>
/// <em>Note: The server receives this message from all clients (including itself).
/// Each client receives their own notification sent to the server.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnLoadCompleteDelegateHandler OnLoadComplete;
/// <summary>
/// Invoked when a <see cref="SceneEventType.UnloadComplete"/> event is generated by a client or server.<br/>
/// <em>Note: The server receives this message from all clients (including itself).
/// Each client receives their own notification sent to the server.</em><br/>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnUnloadCompleteDelegateHandler OnUnloadComplete;
/// <summary>
/// Invoked when a <see cref="SceneEventType.SynchronizeComplete"/> event is generated by a client. <br/>
/// <em> Note: The server receives this message from the client, but will never generate this event for itself.
/// Each client receives their own notification sent to the server. This is useful to know that a client has
/// completed the entire connection sequence, loaded all scenes, and synchronized all NetworkObjects.</em>
/// <em>*** Do not start new scene events within scene event notification callbacks.</em><br/>
/// </summary>
public event OnSynchronizeCompleteDelegateHandler OnSynchronizeComplete;
/// <summary>
/// Delegate declaration for the <see cref="VerifySceneBeforeLoading"/> handler that provides
/// an additional level of scene loading security and/or validation to assure the scene being loaded
/// is valid scene to be loaded in the LoadSceneMode specified.
/// </summary>
/// <param name="sceneIndex">Build Settings Scenes in Build List index of the scene</param>
/// <param name="sceneName">Name of the scene</param>
/// <param name="loadSceneMode">LoadSceneMode the scene is going to be loaded</param>
/// <returns>true (valid) or false (not valid)</returns>
public delegate bool VerifySceneBeforeLoadingDelegateHandler(int sceneIndex, string sceneName, LoadSceneMode loadSceneMode);
/// <summary>
/// Delegate handler defined by <see cref="VerifySceneBeforeLoadingDelegateHandler"/> that is invoked before the
/// server or client loads a scene during an active netcode game session.<br/>
/// <b>Client Side:</b> In order for clients to be notified of this condition you must assign the <see cref="VerifySceneBeforeLoading"/> delegate handler.<br/>
/// <b>Server Side:</b> <see cref="LoadScene(string, LoadSceneMode)"/> will return <see cref="SceneEventProgressStatus"/>.
/// </summary>
public VerifySceneBeforeLoadingDelegateHandler VerifySceneBeforeLoading;
/// <summary>
/// The SceneManagerHandler implementation
/// </summary>
internal ISceneManagerHandler SceneManagerHandler = new DefaultSceneManagerHandler();
/// <summary>
/// The default SceneManagerHandler that interfaces between the SceneManager and NetworkSceneManager
/// </summary>
private class DefaultSceneManagerHandler : ISceneManagerHandler
{
public AsyncOperation LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode, SceneEventProgress sceneEventProgress)
{
var operation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
sceneEventProgress.SetAsyncOperation(operation);
return operation;
}
public AsyncOperation UnloadSceneAsync(Scene scene, SceneEventProgress sceneEventProgress)
{
var operation = SceneManager.UnloadSceneAsync(scene);
sceneEventProgress.SetAsyncOperation(operation);
return operation;
}
}
internal readonly Dictionary<Guid, SceneEventProgress> SceneEventProgressTracking = new Dictionary<Guid, SceneEventProgress>();
/// <summary>
/// Used to track in-scene placed NetworkObjects
/// We store them by:
/// [GlobalObjectIdHash][Scene.Handle][NetworkObject]
/// The Scene.Handle aspect allows us to distinguish duplicated in-scene placed NetworkObjects created by the loading
/// of the same additive scene multiple times.
/// </summary>
internal readonly Dictionary<uint, Dictionary<int, NetworkObject>> ScenePlacedObjects = new Dictionary<uint, Dictionary<int, NetworkObject>>();
/// <summary>
/// This is used for the deserialization of in-scene placed NetworkObjects in order to distinguish duplicated in-scene
/// placed NetworkObjects created by the loading of the same additive scene multiple times.
/// </summary>
internal Scene SceneBeingSynchronized;
/// <summary>
/// Used to track which scenes are currently loaded
/// We store the scenes as [SceneHandle][Scene] in order to handle the loading and unloading of the same scene additively
/// Scene handle is only unique locally. So, clients depend upon the <see cref="ServerSceneHandleToClientSceneHandle"/> in order
/// to be able to know which specific scene instance the server is instructing the client to unload.
/// The client links the server scene handle to the client local scene handle upon a scene being loaded
/// <see cref="GetAndAddNewlyLoadedSceneByName"/>
/// </summary>
internal Dictionary<int, Scene> ScenesLoaded = new Dictionary<int, Scene>();
/// <summary>
/// Since Scene.handle is unique per client, we create a look-up table between the client and server to associate server unique scene
/// instances with client unique scene instances
/// </summary>
internal Dictionary<int, int> ServerSceneHandleToClientSceneHandle = new Dictionary<int, int>();
/// <summary>
/// Hash to build index lookup table
/// </summary>
internal Dictionary<uint, int> HashToBuildIndex = new Dictionary<uint, int>();
/// <summary>
/// Build index to hash lookup table
/// </summary>
internal Dictionary<int, uint> BuildIndexToHash = new Dictionary<int, uint>();
/// <summary>
/// The Condition: While a scene is asynchronously loaded in single loading scene mode, if any new NetworkObjects are spawned
/// they need to be moved into the do not destroy temporary scene
/// When it is set: Just before starting the asynchronous loading call
/// When it is unset: After the scene has loaded, the PopulateScenePlacedObjects is called, and all NetworkObjects in the do
/// not destroy temporary scene are moved into the active scene
/// </summary>
internal static bool IsSpawnedObjectsPendingInDontDestroyOnLoad;
/// <summary>
/// Client and Server:
/// Used for all scene event processing
/// </summary>
internal Dictionary<uint, SceneEventData> SceneEventDataStore;
private NetworkManager m_NetworkManager { get; }
internal Scene DontDestroyOnLoadScene;
/// <summary>
/// <b>LoadSceneMode.Single:</b> All currently loaded scenes on the client will be unloaded and
/// the server's currently active scene will be loaded in single mode on the client
/// unless it was already loaded.<br/>
/// <b>LoadSceneMode.Additive:</b> All currently loaded scenes are left as they are and any newly loaded
/// scenes will be loaded additively. Users need to determine which scenes are valid to load via the
/// <see cref="VerifySceneBeforeLoading"/> method.
/// </summary>
public LoadSceneMode ClientSynchronizationMode { get; internal set; }
/// <summary>
/// When true, the <see cref="Debug.LogWarning(object)"/> messages will be turned off
/// </summary>
private bool m_DisableValidationWarningMessages;
/// <summary>
/// Handle NetworkSeneManager clean up
/// </summary>
public void Dispose()
{
SceneUnloadEventHandler.Shutdown();
foreach (var keypair in SceneEventDataStore)
{
if (NetworkLog.CurrentLogLevel <= LogLevel.Normal)
{
NetworkLog.LogInfo($"{nameof(SceneEventDataStore)} is disposing {nameof(SceneEventData.SceneEventId)} '{keypair.Key}'.");
}
keypair.Value.Dispose();
}
SceneEventDataStore.Clear();
SceneEventDataStore = null;
}
/// <summary>
/// Creates a new SceneEventData object for a new scene event
/// </summary>
/// <returns>SceneEventData instance</returns>
internal SceneEventData BeginSceneEvent()
{
var sceneEventData = new SceneEventData(m_NetworkManager);
SceneEventDataStore.Add(sceneEventData.SceneEventId, sceneEventData);
return sceneEventData;
}
/// <summary>
/// Disposes and removes SceneEventData object for the scene event
/// </summary>
/// <param name="sceneEventId">SceneEventId to end</param>
internal void EndSceneEvent(uint sceneEventId)
{
if (SceneEventDataStore.ContainsKey(sceneEventId))
{
SceneEventDataStore[sceneEventId].Dispose();
SceneEventDataStore.Remove(sceneEventId);
}
else
{
Debug.LogWarning($"Trying to dispose and remove SceneEventData Id '{sceneEventId}' that no longer exists!");
}
}
/// <summary>
/// Gets the scene name from full path to the scene
/// </summary>
internal string GetSceneNameFromPath(string scenePath)
{
var begin = scenePath.LastIndexOf("/", StringComparison.Ordinal) + 1;
var end = scenePath.LastIndexOf(".", StringComparison.Ordinal);
return scenePath.Substring(begin, end - begin);
}
/// <summary>
/// Generates the hash values and associated tables
/// for the scenes in build list
/// </summary>
internal void GenerateScenesInBuild()
{
HashToBuildIndex.Clear();
BuildIndexToHash.Clear();
for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
{
var scenePath = SceneUtility.GetScenePathByBuildIndex(i);
var hash = XXHash.Hash32(scenePath);
var buildIndex = SceneUtility.GetBuildIndexByScenePath(scenePath);
// In the rare-case scenario where a programmatically generated build has duplicate
// scene entries, we will log an error and skip the entry
if (!HashToBuildIndex.ContainsKey(hash))
{
HashToBuildIndex.Add(hash, buildIndex);
BuildIndexToHash.Add(buildIndex, hash);
}
else
{
Debug.LogError($"{nameof(NetworkSceneManager)} is skipping duplicate scene path entry {scenePath}. Make sure your scenes in build list does not contain duplicates!");
}
}
}
/// <summary>
/// Gets the scene name from a hash value generated from the full scene path
/// </summary>
internal string SceneNameFromHash(uint sceneHash)
{
// In the event there is no scene associated with the scene event then just return "No Scene"
// This can happen during unit tests when clients first connect and the only scene loaded is the
// unit test scene (which is ignored by default) that results in a scene event that has no associated
// scene. Under this specific special case, we just return "No Scene".
if (sceneHash == 0)
{
return "No Scene";
}
return GetSceneNameFromPath(ScenePathFromHash(sceneHash));
}
/// <summary>
/// Gets the full scene path from a hash value
/// </summary>
internal string ScenePathFromHash(uint sceneHash)
{
if (HashToBuildIndex.ContainsKey(sceneHash))
{
return SceneUtility.GetScenePathByBuildIndex(HashToBuildIndex[sceneHash]);
}
else
{
throw new Exception($"Scene Hash {sceneHash} does not exist in the {nameof(HashToBuildIndex)} table! Verify that all scenes requiring" +
$" server to client synchronization are in the scenes in build list.");
}
}
/// <summary>
/// Gets the associated hash value for the scene name or path
/// </summary>
internal uint SceneHashFromNameOrPath(string sceneNameOrPath)
{
var buildIndex = SceneUtility.GetBuildIndexByScenePath(sceneNameOrPath);
if (buildIndex >= 0)
{
if (BuildIndexToHash.ContainsKey(buildIndex))
{
return BuildIndexToHash[buildIndex];
}
else
{
throw new Exception($"Scene '{sceneNameOrPath}' has a build index of {buildIndex} that does not exist in the {nameof(BuildIndexToHash)} table!");
}
}
else
{
throw new Exception($"Scene '{sceneNameOrPath}' couldn't be loaded because it has not been added to the build settings scenes in build list.");
}
}
/// <summary>
/// When set to true, this will disable the console warnings about
/// a scene being invalidated.
/// </summary>
/// <param name="disabled">true/false</param>
public void DisableValidationWarnings(bool disabled)
{
m_DisableValidationWarningMessages = disabled;
}
/// <summary>
/// This will change how clients are initially synchronized.<br/>
/// <b>LoadSceneMode.Single:</b> All currently loaded scenes on the client will be unloaded and
/// the server's currently active scene will be loaded in single mode on the client
/// unless it was already loaded. <br/>
/// <b>LoadSceneMode.Additive:</b> All currently loaded scenes are left as they are and any newly loaded
/// scenes will be loaded additively. Users need to determine which scenes are valid to load via the
/// <see cref="VerifySceneBeforeLoading"/> method.
/// </summary>
/// <param name="mode"><see cref="LoadSceneMode"/> for initial client synchronization</param>
public void SetClientSynchronizationMode(LoadSceneMode mode)
{
ClientSynchronizationMode = mode;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="networkManager">one <see cref="NetworkManager"/> instance per <see cref="NetworkSceneManager"/> instance</param>
/// <param name="sceneEventDataPoolSize">maximum <see cref="SceneEventData"/> pool size</param>
internal NetworkSceneManager(NetworkManager networkManager)
{
m_NetworkManager = networkManager;
SceneEventDataStore = new Dictionary<uint, SceneEventData>();
GenerateScenesInBuild();
// Since NetworkManager is now always migrated to the DDOL we will use this to get the DDOL scene
DontDestroyOnLoadScene = networkManager.gameObject.scene;
ServerSceneHandleToClientSceneHandle.Add(DontDestroyOnLoadScene.handle, DontDestroyOnLoadScene.handle);
ScenesLoaded.Add(DontDestroyOnLoadScene.handle, DontDestroyOnLoadScene);
}
/// <summary>
/// If the VerifySceneBeforeLoading delegate handler has been set by the user, this will provide
/// an additional level of security and/or validation that the scene being loaded in the specified
/// loading mode is "a valid scene to be loaded in the LoadSceneMode specified".
/// </summary>
/// <param name="sceneIndex">index into ScenesInBuild</param>
/// <param name="loadSceneMode">LoadSceneMode the scene is going to be loaded</param>
/// <returns>true (Valid) or false (Invalid)</returns>
internal bool ValidateSceneBeforeLoading(uint sceneHash, LoadSceneMode loadSceneMode)
{
var validated = true;
var sceneName = SceneNameFromHash(sceneHash);
var sceneIndex = SceneUtility.GetBuildIndexByScenePath(sceneName);
if (VerifySceneBeforeLoading != null)
{
validated = VerifySceneBeforeLoading.Invoke((int)sceneIndex, sceneName, loadSceneMode);
}
if (!validated && !m_DisableValidationWarningMessages)
{
var serverHostorClient = "Client";
if (m_NetworkManager.IsServer)
{
serverHostorClient = m_NetworkManager.IsHost ? "Host" : "Server";
}
Debug.LogWarning($"Scene {sceneName} of Scenes in Build Index {sceneIndex} being loaded in {loadSceneMode} mode failed validation on the {serverHostorClient}!");
}
return validated;
}
/// <summary>
/// Used for NetcodeIntegrationTest testing in order to properly
/// assign the right loaded scene to the right client's ScenesLoaded list
/// </summary>
internal Func<string, Scene> OverrideGetAndAddNewlyLoadedSceneByName;
/// <summary>
/// Since SceneManager.GetSceneByName only returns the first scene that matches the name
/// we must "find" a newly added scene by looking through all loaded scenes and determining
/// which scene with the same name has not yet been loaded.
/// In order to support loading the same additive scene within in-scene placed NetworkObjects,
/// we must do this to be able to soft synchronize the "right version" of the NetworkObject.
/// </summary>
/// <param name="sceneName"></param>
/// <returns></returns>
internal Scene GetAndAddNewlyLoadedSceneByName(string sceneName)
{
if (OverrideGetAndAddNewlyLoadedSceneByName != null)
{
return OverrideGetAndAddNewlyLoadedSceneByName.Invoke(sceneName);
}
else
{
for (int i = 0; i < SceneManager.sceneCount; i++)
{
var sceneLoaded = SceneManager.GetSceneAt(i);
if (sceneLoaded.name == sceneName)
{
if (!ScenesLoaded.ContainsKey(sceneLoaded.handle))
{
ScenesLoaded.Add(sceneLoaded.handle, sceneLoaded);
return sceneLoaded;
}
}
}
throw new Exception($"Failed to find any loaded scene named {sceneName}!");
}
}
/// <summary>
/// Client Side Only:
/// This takes a server scene handle that is written by the server before the scene relative
/// NetworkObject is serialized and converts the server scene handle to a local client handle
/// so it can set the appropriate SceneBeingSynchronized.
/// Note: This is now part of the soft synchronization process and is needed for the scenario
/// where a user loads the same scene additively that has an in-scene placed NetworkObject
/// which means each scene relative in-scene placed NetworkObject will have the identical GlobalObjectIdHash
/// value. Scene handles are used to distinguish between in-scene placed NetworkObjects under this situation.
/// </summary>
/// <param name="serverSceneHandle"></param>
internal void SetTheSceneBeingSynchronized(int serverSceneHandle)
{
var clientSceneHandle = serverSceneHandle;
if (ServerSceneHandleToClientSceneHandle.ContainsKey(serverSceneHandle))
{
clientSceneHandle = ServerSceneHandleToClientSceneHandle[serverSceneHandle];
// If we were already set, then ignore
if (SceneBeingSynchronized.IsValid() && SceneBeingSynchronized.isLoaded && SceneBeingSynchronized.handle == clientSceneHandle)
{
return;
}
// Get the scene currently being synchronized
SceneBeingSynchronized = ScenesLoaded.ContainsKey(clientSceneHandle) ? ScenesLoaded[clientSceneHandle] : new Scene();
if (!SceneBeingSynchronized.IsValid() || !SceneBeingSynchronized.isLoaded)
{
// Let's go ahead and use the currently active scene under the scenario where a NetworkObject is determined to exist in a scene that the NetworkSceneManager is not aware of
SceneBeingSynchronized = SceneManager.GetActiveScene();
// Keeping the warning here in the event we cannot find the scene being synchronized
Debug.LogWarning($"[{nameof(NetworkSceneManager)}- {nameof(ScenesLoaded)}] Could not find the appropriate scene to set as being synchronized! Using the currently active scene.");
}
}
else
{
// Most common scenario for DontDestroyOnLoad is when NetworkManager is set to not be destroyed
if (serverSceneHandle == DontDestroyOnLoadScene.handle)
{
SceneBeingSynchronized = m_NetworkManager.gameObject.scene;
return;
}
else
{
// Let's go ahead and use the currently active scene under the scenario where a NetworkObject is determined to exist in a scene that the NetworkSceneManager is not aware of
// or the NetworkObject has yet to be moved to that specific scene (i.e. no DontDestroyOnLoad scene exists yet).
SceneBeingSynchronized = SceneManager.GetActiveScene();
// This could be the scenario where NetworkManager.DontDestroy is false and we are creating the first NetworkObject (client side) to be in the DontDestroyOnLoad scene
// Otherwise, this is some other specific scenario that we might not be handling currently.
Debug.LogWarning($"[{nameof(SceneEventData)}- Scene Handle Mismatch] {nameof(serverSceneHandle)} could not be found in {nameof(ServerSceneHandleToClientSceneHandle)}. Using the currently active scene.");
}
}
}
/// <summary>
/// During soft synchronization of in-scene placed NetworkObjects, this is now used by NetworkSpawnManager.CreateLocalNetworkObject
/// </summary>
/// <param name="globalObjectIdHash"></param>
/// <returns></returns>
internal NetworkObject GetSceneRelativeInSceneNetworkObject(uint globalObjectIdHash, int? networkSceneHandle)
{
if (ScenePlacedObjects.ContainsKey(globalObjectIdHash))
{
var sceneHandle = SceneBeingSynchronized.handle;
if (networkSceneHandle.HasValue && networkSceneHandle.Value != 0)
{
sceneHandle = ServerSceneHandleToClientSceneHandle[networkSceneHandle.Value];
}
if (ScenePlacedObjects[globalObjectIdHash].ContainsKey(sceneHandle))
{
return ScenePlacedObjects[globalObjectIdHash][sceneHandle];
}
}
return null;
}
/// <summary>
/// Generic sending of scene event data
/// </summary>
/// <param name="targetClientIds">array of client identifiers to receive the scene event message</param>
private void SendSceneEventData(uint sceneEventId, ulong[] targetClientIds)
{
if (targetClientIds.Length == 0)
{
// This would be the Host/Server with no clients connected
// Silently return as there is nothing to be done
return;
}
var message = new SceneEventMessage
{
EventData = SceneEventDataStore[sceneEventId]
};
var size = m_NetworkManager.SendMessage(ref message, k_DeliveryType, targetClientIds);
m_NetworkManager.NetworkMetrics.TrackSceneEventSent(targetClientIds, (uint)SceneEventDataStore[sceneEventId].SceneEventType, SceneNameFromHash(SceneEventDataStore[sceneEventId].SceneHash), size);
}
/// <summary>
/// Entry method for scene unloading validation
/// </summary>
/// <param name="scene">the scene to be unloaded</param>
/// <returns></returns>
private SceneEventProgress ValidateSceneEventUnLoading(Scene scene)
{
if (!m_NetworkManager.IsServer)
{
throw new NotServerException("Only server can start a scene event!");
}
if (!m_NetworkManager.NetworkConfig.EnableSceneManagement)
{
//Log message about enabling SceneManagement
throw new Exception($"{nameof(NetworkConfig.EnableSceneManagement)} flag is not enabled in the {nameof(NetworkManager)}'s {nameof(NetworkConfig)}. " +
$"Please set {nameof(NetworkConfig.EnableSceneManagement)} flag to true before calling " +
$"{nameof(NetworkSceneManager.LoadScene)} or {nameof(NetworkSceneManager.UnloadScene)}.");
}
if (!scene.isLoaded)
{
Debug.LogWarning($"{nameof(UnloadScene)} was called, but the scene {scene.name} is not currently loaded!");
return new SceneEventProgress(null, SceneEventProgressStatus.SceneNotLoaded);
}
return ValidateSceneEvent(scene.name, true);
}
/// <summary>
/// Entry method for scene loading validation
/// </summary>
/// <param name="sceneName">scene name to load</param>
/// <returns></returns>
private SceneEventProgress ValidateSceneEventLoading(string sceneName)
{
if (!m_NetworkManager.IsServer)
{
throw new NotServerException("Only server can start a scene event!");
}
if (!m_NetworkManager.NetworkConfig.EnableSceneManagement)
{
//Log message about enabling SceneManagement
throw new Exception($"{nameof(NetworkConfig.EnableSceneManagement)} flag is not enabled in the {nameof(NetworkManager)}'s {nameof(NetworkConfig)}. " +
$"Please set {nameof(NetworkConfig.EnableSceneManagement)} flag to true before calling " +
$"{nameof(NetworkSceneManager.LoadScene)} or {nameof(NetworkSceneManager.UnloadScene)}.");
}
return ValidateSceneEvent(sceneName);
}
/// <summary>
/// Validates the new scene event request by the server-side code.
/// This also initializes some commonly shared values as well as SceneEventProgress
/// </summary>
/// <param name="sceneName"></param>
/// <returns><see cref="SceneEventProgress"/> that should have a <see cref="SceneEventProgress.Status"/> of <see cref="SceneEventProgressStatus.Started"/> otherwise it failed.</returns>
private SceneEventProgress ValidateSceneEvent(string sceneName, bool isUnloading = false)
{
// Return scene event already in progress if one is already in progress
if (m_IsSceneEventActive)
{
return new SceneEventProgress(null, SceneEventProgressStatus.SceneEventInProgress);
}
// Return invalid scene name status if the scene name is invalid
if (SceneUtility.GetBuildIndexByScenePath(sceneName) == InvalidSceneNameOrPath)
{
Debug.LogError($"Scene '{sceneName}' couldn't be loaded because it has not been added to the build settings scenes in build list.");
return new SceneEventProgress(null, SceneEventProgressStatus.InvalidSceneName);
}
var sceneEventProgress = new SceneEventProgress(m_NetworkManager)
{
SceneHash = SceneHashFromNameOrPath(sceneName)
};
SceneEventProgressTracking.Add(sceneEventProgress.Guid, sceneEventProgress);
if (!isUnloading)
{
// The Condition: While a scene is asynchronously loaded in single loading scene mode, if any new NetworkObjects are spawned
// they need to be moved into the do not destroy temporary scene
// When it is set: Just before starting the asynchronous loading call
// When it is unset: After the scene has loaded, the PopulateScenePlacedObjects is called, and all NetworkObjects in the do
// not destroy temporary scene are moved into the active scene
IsSpawnedObjectsPendingInDontDestroyOnLoad = true;
}
m_IsSceneEventActive = true;
// Set our callback delegate handler for completion
sceneEventProgress.OnComplete = OnSceneEventProgressCompleted;
return sceneEventProgress;
}
/// <summary>
/// Callback for the <see cref="SceneEventProgress.OnComplete"/> <see cref="SceneEventProgress.OnCompletedDelegate"/> handler
/// </summary>
/// <param name="sceneEventProgress"></param>
private bool OnSceneEventProgressCompleted(SceneEventProgress sceneEventProgress)
{
var sceneEventData = BeginSceneEvent();
var clientsThatCompleted = sceneEventProgress.GetClientsWithStatus(true);
var clientsThatTimedOut = sceneEventProgress.GetClientsWithStatus(false);
sceneEventData.SceneEventProgressId = sceneEventProgress.Guid;
sceneEventData.SceneHash = sceneEventProgress.SceneHash;
sceneEventData.SceneEventType = sceneEventProgress.SceneEventType;
sceneEventData.ClientsCompleted = clientsThatCompleted;
sceneEventData.LoadSceneMode = sceneEventProgress.LoadSceneMode;
sceneEventData.ClientsTimedOut = clientsThatTimedOut;
var message = new SceneEventMessage
{
EventData = sceneEventData
};
var size = m_NetworkManager.SendMessage(ref message, k_DeliveryType, m_NetworkManager.ConnectedClientsIds);
m_NetworkManager.NetworkMetrics.TrackSceneEventSent(
m_NetworkManager.ConnectedClientsIds,
(uint)sceneEventProgress.SceneEventType,
SceneNameFromHash(sceneEventProgress.SceneHash),
size);
// Send a local notification to the server that all clients are done loading or unloading
OnSceneEvent?.Invoke(new SceneEvent()
{
SceneEventType = sceneEventProgress.SceneEventType,
SceneName = SceneNameFromHash(sceneEventProgress.SceneHash),
ClientId = NetworkManager.ServerClientId,
LoadSceneMode = sceneEventProgress.LoadSceneMode,
ClientsThatCompleted = clientsThatCompleted,
ClientsThatTimedOut = clientsThatTimedOut,
});
if (sceneEventData.SceneEventType == SceneEventType.LoadEventCompleted)
{
OnLoadEventCompleted?.Invoke(SceneNameFromHash(sceneEventProgress.SceneHash), sceneEventProgress.LoadSceneMode, sceneEventData.ClientsCompleted, sceneEventData.ClientsTimedOut);
}
else
{
OnUnloadEventCompleted?.Invoke(SceneNameFromHash(sceneEventProgress.SceneHash), sceneEventProgress.LoadSceneMode, sceneEventData.ClientsCompleted, sceneEventData.ClientsTimedOut);
}
EndSceneEvent(sceneEventData.SceneEventId);
return true;
}
/// <summary>
/// <b>Server Side:</b>
/// Unloads an additively loaded scene. If you want to unload a <see cref="LoadSceneMode.Single"/> mode loaded scene load another <see cref="LoadSceneMode.Single"/> scene.
/// When applicable, the <see cref="AsyncOperation"/> is delivered within the <see cref="SceneEvent"/> via the <see cref="OnSceneEvent"/>
/// </summary>
/// <param name="scene"></param>
/// <returns><see cref="SceneEventProgressStatus"/> (<see cref="SceneEventProgressStatus.Started"/> means it was successful)</returns>
public SceneEventProgressStatus UnloadScene(Scene scene)
{
var sceneName = scene.name;
var sceneHandle = scene.handle;
if (!scene.isLoaded)
{
Debug.LogWarning($"{nameof(UnloadScene)} was called, but the scene {scene.name} is not currently loaded!");
return SceneEventProgressStatus.SceneNotLoaded;
}
var sceneEventProgress = ValidateSceneEventUnLoading(scene);
if (sceneEventProgress.Status != SceneEventProgressStatus.Started)
{
return sceneEventProgress.Status;
}
if (!ScenesLoaded.ContainsKey(sceneHandle))
{
Debug.LogError($"{nameof(UnloadScene)} internal error! {sceneName} with handle {scene.handle} is not within the internal scenes loaded dictionary!");
return SceneEventProgressStatus.InternalNetcodeError;
}
var sceneEventData = BeginSceneEvent();
sceneEventData.SceneEventProgressId = sceneEventProgress.Guid;
sceneEventData.SceneEventType = SceneEventType.Unload;
sceneEventData.SceneHash = SceneHashFromNameOrPath(sceneName);
sceneEventData.LoadSceneMode = LoadSceneMode.Additive; // The only scenes unloaded are scenes that were additively loaded
sceneEventData.SceneHandle = sceneHandle;
// This will be the message we send to everyone when this scene event sceneEventProgress is complete
sceneEventProgress.SceneEventType = SceneEventType.UnloadEventCompleted;
ScenesLoaded.Remove(scene.handle);
sceneEventProgress.SceneEventId = sceneEventData.SceneEventId;
sceneEventProgress.OnSceneEventCompleted = OnSceneUnloaded;
var sceneUnload = SceneManagerHandler.UnloadSceneAsync(scene, sceneEventProgress);
// Notify local server that a scene is going to be unloaded
OnSceneEvent?.Invoke(new SceneEvent()
{
AsyncOperation = sceneUnload,
SceneEventType = sceneEventData.SceneEventType,
LoadSceneMode = sceneEventData.LoadSceneMode,
SceneName = sceneName,
ClientId = NetworkManager.ServerClientId // Server can only invoke this
});
OnUnload?.Invoke(NetworkManager.ServerClientId, sceneName, sceneUnload);
//Return the status
return sceneEventProgress.Status;
}
/// <summary>
/// <b>Client Side:</b>
/// Handles <see cref="SceneEventType.Unload"/> scene events.
/// </summary>
private void OnClientUnloadScene(uint sceneEventId)
{
var sceneEventData = SceneEventDataStore[sceneEventId];