Class NetworkSceneManager
Main class for managing network scenes when Enable
Implements
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.Netcode.Runtime.dll
Syntax
public class NetworkSceneManager : IDisposable
Fields
PostSynchronizationSceneUnloading
When enabled and Client
Declaration
public bool PostSynchronizationSceneUnloading
Field Value
Type | Description |
---|---|
bool |
Remarks
If the Verify
VerifySceneBeforeLoading
Delegate handler defined by Network
Declaration
public NetworkSceneManager.VerifySceneBeforeLoadingDelegateHandler VerifySceneBeforeLoading
Field Value
Type | Description |
---|---|
Network |
Remarks
Client Side: In order for clients to be notified of this condition you must assign the Verify
Server Side: Load
VerifySceneBeforeUnloading
Client Side Only:
Delegate handler defined by Network
Declaration
public NetworkSceneManager.VerifySceneBeforeUnloadingDelegateHandler VerifySceneBeforeUnloading
Field Value
Type | Description |
---|---|
Network |
Properties
ActiveSceneSynchronizationEnabled
When enabled, the server or host will synchronize clients with changes to the currently active scene
Declaration
public bool ActiveSceneSynchronizationEnabled { get; set; }
Property Value
Type | Description |
---|---|
bool |
ClientSynchronizationMode
This setting changes how clients handle scene loading when initially synchronizing with the server.
See: Set
Declaration
public LoadSceneMode ClientSynchronizationMode { get; }
Property Value
Type | Description |
---|---|
Load |
Remarks
LoadSceneMode.Single: 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.
LoadSceneMode.Additive: 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
Verify
Methods
DisableValidationWarnings(bool)
When set to true, this will disable the console warnings about a scene being invalidated.
Declaration
public void DisableValidationWarnings(bool disabled)
Parameters
Type | Name | Description |
---|---|---|
bool | disabled | true/false |
Dispose()
Handle NetworkSeneManager clean up
Declaration
public void Dispose()
LoadScene(string, LoadSceneMode)
Server side:
Loads the scene name in either additive or single loading mode.
When applicable, the Async
Declaration
public SceneEventProgressStatus LoadScene(string sceneName, LoadSceneMode loadSceneMode)
Parameters
Type | Name | Description |
---|---|---|
string | sceneName | the name of the scene to be loaded |
Load |
loadSceneMode | how the scene will be loaded (single or additive mode) |
Returns
Type | Description |
---|---|
Scene |
Scene |
SetClientSynchronizationMode(LoadSceneMode)
Declaration
public void SetClientSynchronizationMode(LoadSceneMode mode)
Parameters
Type | Name | Description |
---|---|---|
Load |
mode |
UnloadScene(Scene)
Server Side:
Unloads an additively loaded scene. If you want to unload a Single mode loaded scene load another Single scene.
When applicable, the Async
Declaration
public SceneEventProgressStatus UnloadScene(Scene scene)
Parameters
Type | Name | Description |
---|---|---|
Scene | scene |
Returns
Type | Description |
---|---|
Scene |
Scene |
Events
OnLoad
Invoked when a Load event is started by the server.
Note: The server and connected client(s) will always receive this notification.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnLoadDelegateHandler OnLoad
Event Type
Type | Description |
---|---|
Network |
OnLoadComplete
Invoked when a Load
Note: The server receives this message from all clients (including itself).
Each client receives their own notification sent to the server.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnLoadCompleteDelegateHandler OnLoadComplete
Event Type
Type | Description |
---|---|
Network |
OnLoadEventCompleted
Invoked when a Load
Note: this is useful to know when all clients have loaded the same scene (single or additive mode)
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnEventCompletedDelegateHandler OnLoadEventCompleted
Event Type
Type | Description |
---|---|
Network |
OnSceneEvent
Subscribe to this event to receive all Scene
For more details review over Scene
Alternate Single Event Type Notification Registration Options
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:
- On
Load Invoked only when a Load event is being processed - On
Unload Invoked only when an Unload event is being processed - On
Synchronize Invoked only when a Synchronize event is being processed - On
Load Invoked only when a LoadEvent Completed Event event is being processedCompleted - On
Unload Invoked only when an UnloadEvent Completed Event event is being processedCompleted - On
Load Invoked only when a LoadComplete Complete event is being processed - On
Unload Invoked only when an UnloadComplete Complete event is being processed - On
Synchronize Invoked only when a SynchronizeComplete Complete event is being processed
Declaration
public event NetworkSceneManager.SceneEventDelegate OnSceneEvent
Event Type
Type | Description |
---|---|
Network |
OnSynchronize
Invoked when a 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.
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.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnSynchronizeDelegateHandler OnSynchronize
Event Type
Type | Description |
---|---|
Network |
OnSynchronizeComplete
Invoked when a Synchronize
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.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnSynchronizeCompleteDelegateHandler OnSynchronizeComplete
Event Type
Type | Description |
---|---|
Network |
OnUnload
Invoked when a Unload event is started by the server.
Note: The server and connected client(s) will always receive this notification.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnUnloadDelegateHandler OnUnload
Event Type
Type | Description |
---|---|
Network |
OnUnloadComplete
Invoked when a Unload
Note: The server receives this message from all clients (including itself).
Each client receives their own notification sent to the server.
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnUnloadCompleteDelegateHandler OnUnloadComplete
Event Type
Type | Description |
---|---|
Network |
OnUnloadEventCompleted
Invoked when a Unload
Note: this is useful to know when all clients have unloaded a specific scene. The Load
*** Do not start new scene events within scene event notification callbacks.
Declaration
public event NetworkSceneManager.OnEventCompletedDelegateHandler OnUnloadEventCompleted
Event Type
Type | Description |
---|---|
Network |