NetworkManager
Singleton MonoBehaviour that serves as the central entry point for all networking operations. Wraps Unity Netcode's NetworkManager with a higher-level API for service connection, session management, network object spawning, custom messaging, and prefab handler registration.
Definition
Namespace: Paragon.Core.Network Assembly: Paragon.dll
[RequireComponent(typeof(Unity.Netcode.NetworkManager))]
[SingletonSettings(InitializeOnLoad = true, DontDestroyOnLoad = true, AssetPath = "Network Manager")]
public class NetworkManager : SingletonBehaviour<NetworkManager>Inheritance: ParagonBehaviour → SingletonBehaviour<NetworkManager> → NetworkManager
Remarks
NetworkManager is the Paragon wrapper around Unity's Unity.Netcode.NetworkManager (aliased internally as UnityNetworkManager). It orchestrates:
Service lifecycle — connecting to a network service (Unity Gaming Services, Steam, etc.) and signing in.
Session management — creating, joining, leaving, and stopping multiplayer sessions.
Object spawning — instantiating prefabs and immediately network-spawning them.
Custom messaging — subscribing to and sending typed messages through the
NetworkMessenger.Prefab handlers — registering custom
INetworkPrefabInstanceHandlerfor pooled or factory-spawned objects.
The manager is loaded from Resources/Network Manager.prefab and persists across scene loads. It sets the scene synchronization mode to Additive when the server starts.
Several methods are decorated with [RuntimeCommand], making them callable from the Paragon runtime command console.
Quick Lookup
Access the singleton
NetworkManager.Instance
Connect to services
await NetworkManager.Connect()
Quick-start a session
await NetworkManager.QuickStart()
Leave session
NetworkManager.LeaveSession()
Disconnect entirely
NetworkManager.Disconnect()
Spawn a network object
NetworkManager.InstantiateAndSpawn(prefab)
Send a typed message
NetworkManager.SendMessage("id", message, targetIds)
Subscribe to messages
NetworkManager.SubscribeToMessage<T>("id", callback)
Check connection state
NetworkManager.IsConnected
Check role
NetworkManager.IsHost / IsClient / IsServer
Get local client ID
NetworkManager.ClientId
Get server client ID
NetworkManager.ServerId
Access underlying API
NetworkManager.API (internal)
Wait for connection
await NetworkManager.WaitForClientConnection()
Properties
Connection State
IsConnected
bool
true if the application is playing and the service adapter is connected
IsClient
bool
true if running as a client
IsHost
bool
true if running as host (client + server)
IsServer
bool
true if running as a dedicated server
ClientId
ulong
Local client's network ID
ServerId
ulong
The server's client ID (constant 0)
Services
ServiceType
NetworkServiceType
The configured service backend (UNITY, STEAM, EPIC)
Service
NetworkService
The active service instance for session management
Messenger
NetworkMessenger
The custom messaging system
Internal
API
Unity.Netcode.NetworkManager
Direct access to the underlying Netcode manager (internal)
Methods
Connect
Connects to the configured network service and signs in anonymously.
Guard: Logs an error and returns if already connected. Always check IsConnected if calling manually.
QuickStart
Connects (if needed) then automatically creates or joins a session.
LeaveSession
Leaves the current session.
Disconnect
Disconnects from the network service entirely.
StopSession
Leaves the current session (alias for LeaveSession).
InstantiateAndSpawn<T>
Instantiates a Unity Object and immediately spawns its NetworkObject.
original
T
The prefab to instantiate (must have a NetworkObject component)
position
Vector3
World position for the instance
rotation
Quaternion
World rotation for the instance
Returns: The instantiated object (with its NetworkObject already spawned).
RegisterPrefabHandler
Registers a custom prefab instance handler for a specific network prefab.
globalObjectIdHash
uint
The network prefab's global object ID hash
handler
INetworkPrefabInstanceHandler
The custom handler for instantiation/destruction
RemovePrefabHandler
Removes a previously registered prefab handler.
SubscribeToMessage<TMessage>
Subscribes to a typed network message on a specific handler ID.
handlerId
string
Unique identifier for the message channel
callback
Action<TMessage>
Callback invoked when a message of this type arrives
SendMessage<TMessage>
Sends a typed network message to specified clients.
handlerId
string
The message channel ID
message
TMessage
The message payload
targetClientIds
ulong[]
Target client IDs. If empty, broadcasts to all other clients.
WaitForClientConnection
Returns a Task that completes when the local client is connected.
Returns immediately if already connected.
QuickStartEditor (Editor Only)
Auto-starts a session using MPPM (Multiplayer Play Mode) tags to determine host vs client role.
Only available in UNITY_EDITOR. Uses the CurrentPlayer.ReadOnlyTags() API to check for a "Client" tag — if present, joins an existing session; otherwise creates one.
Common Pitfalls
Missing NetworkObject component InstantiateAndSpawn calls GetNetworkObject() on the instantiated object. If the prefab lacks a NetworkObject component, it will throw an ArgumentException.
Calling network methods before connection Methods like LeaveSession(), Disconnect(), and SendMessage() guard against being called when not connected, but InstantiateAndSpawn does not. Ensure IsConnected is true before spawning.
Examples
Full Connection Flow
Custom Messaging
See Also
ConnectionData — serialized user identity for connection payloads
NetworkObjectExtensions — per-object messaging and spawning helpers
ParagonNetworkBehaviour — base class for network behaviours
NetworkPlayer — player identity record
Last updated