Scene Managment
ObjectNet provides a powerful system for synchronously loading and unloading scenes across all connected clients. This is essential for transitioning between game levels, zones, or UI states in a multiplayer environment.
Remote Scene Loading
You can remotely load a scene on all clients using:
NetworkManager.Instance().LoadSceneRemote(
string sceneName,
RemoteSceneLoadMode serverLoadMode = RemoteSceneLoadMode.LoadAfter,
LoadSceneMode loadMode = LoadSceneMode.Single,
float loadTimeout = 10f
);
sceneName
The name of the scene to load
ServerLoadMode
Whether the server loads first or after the clients (Default: LoadAfter
), either way they both will open the scene simultaniously
LoadMode
Unity’s scene load type (Single
or Additive
)
LoadTimeout
Maximum time to wait for all clients to load their scenes, prevent clients from hanging if one fails to load
//example
NetworkManager.Instance().LoadSceneRemote("Level1", RemoteSceneLoadMode.LoadAfter, LoadSceneMode.Single, 10);
Remote Scene Unloading
To unload a scene from all clients at once, use:
NetworkManager.Instance().UnloadSceneRemote(
string sceneName,
RemoteSceneUnloadMode serverUnloadMode = RemoteSceneUnloadMode.UnloadAfter,
float loadTimeout = 10f
);
Just like loading, the server can wait for clients or unload first, and a timeout ensures consistency across slower machines.
Important Notes
These methods must be called from the server or host
Scene names must be added to Unity's Build Settings
Timeouts prevent clients from hanging if one fails to load
Use
LoadSceneMode.Additive
if you want to keep the current scene loaded
Last updated