Manual Scene Load
ObjectNet supports multi-scene networking, allowing each player to load and manage scenes independently. This gives you powerful flexibility in designing seamless multiplayer experiences — from lobbies and separate instances to dynamic world streaming.
Players in Different Scenes
Players can be in different scenes at the same time (e.g., Player A in "Scene 1", Player B in "Scene 2"). However, networked player objects still exist across all scenes, meaning:
Each player’s GameObject will still be instantiated on all clients
You are responsible for hiding, disabling, or ignoring remote players who are in other scenes
This enables scene isolation while keeping network presence consistent.
Loading Scenes Manually
You can use Unity's built-in scene management to load scenes manually:
SceneManager.LoadScene("SceneName", LoadSceneMode.Single);
Each client can load scenes independently using standard Unity logic. ObjectNet does not restrict or force scene sync, which is ideal for custom transitions, lobbies, or instancing.
Handling Large Scene Loads
Loading large scenes may cause frame drops or temporarily freeze the main thread, which can lead to false disconnection detection.
To prevent this during loading:
🛑 Pause Disconnection Detection (Server-side)
NetworkManager.Instance().PauseDisconnectDetection(true);
Call this before starting a scene load. It prevents ObjectNet from thinking the client disconnected.
▶️ Resume Detection After Load (Server-side)
NetworkManager.Instance().ResumeDisconnectDetection();
Call this once the scene is fully loaded and ready. Important: Forgetting to resume detection will prevent ObjectNet from detecting actual disconnects later.
Pausing disconnection detection is a double-edged sword.
While it helps prevent false disconnects during heavy operations like scene loading, it also disables ObjectNet’s ability to detect real disconnections.
Always make sure to call ResumeDisconnectDetection()
immediately after the operation is complete.
Failing to resume detection can leave your application unaware of dropped clients.
Controlling Scene Element Instantiation
By default, ObjectNet automatically spawns all relevant networked elements into every scene — even if the player isn't in that scene. You can override this behavior to prevent unwanted elements from being instantiated.
❌ Disable Automatic Scene Elements (Client-side)
NetworkManager.Instance().DisableAutoLoadSceneElements();
Prevents automatic instantiation of remote scene objects
Useful for scenes like lobbies or menus, where you don’t want in-game elements loaded
✅ Enable Auto Scene Elements (Client-side)
NetworkManager.Instance().EnableAutoLoadSceneElements();
Re-enables auto instantiation
Use this after the new scene is fully loaded
Note: Enabling Auto Load Scene Elements does not automatically spawn existing scene elements.
You must manually request them by calling RequestRemoteSceneElements()
.
See the section below for details.
Requesting Scene Elements On Demand
Even if auto-loading is disabled, you can manually request all missing scene elements:
NetworkManager.Instance().RequestRemoteSceneElements();
This will:
Check what scene objects are missing
Spawn only the relevant ones on the current client
Avoid duplication or overload
Last updated