Conversation
Prepare for standalone mode by decoupling consumers from the concrete ConnectionManager. All internal managers (TransformSyncManager, RPCManager, NetworkVariableManager) and NetSyncManager now depend on the IConnectionManager interface instead. No behavioral changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Allow content developers to test with NetSyncManager/NetSyncAvatar without running a server. Enable via Advanced Options > Standalone Mode in the inspector. In this mode: - StandaloneConnectionManager provides a no-op IConnectionManager - Client number is immediately set to 1 - Network variables are stored and read locally with change events - RPCs are looped back to self - Transform sending is silently dropped Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds an offline/standalone-style mode to NetSync so core sync features can run without a server, primarily for local testing, by selecting a no-op connection manager and exposing the option in the Unity inspector.
Changes:
- Added a serialized
_offlineModeoption (with publicIsOfflineMode) and switchedNetSyncManagerto depend onIConnectionManager. - In offline mode,
NetSyncManagerusesOfflineConnectionManagerand short-circuits networking/handshake behavior by assigning a local client number and marking initial sync complete. - Updated the custom inspector property ordering to surface the new
_offlineModetoggle in the “Advanced” foldout.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs |
Adds offline mode toggle, selects IConnectionManager implementation, and adjusts connection/initial-sync behavior for offline operation. |
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Editor/NetSyncManagerEditor.cs |
Exposes _offlineMode in the advanced inspector property order. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _clientNo = 1; | ||
| _networkVariableManager?.MarkInitialSyncComplete(); | ||
| _shouldCheckReady = true; | ||
| DebugLog("Offline mode: client number set to 1, initial sync marked complete"); |
There was a problem hiding this comment.
In offline mode you set _clientNo = 1 directly and return, but this bypasses the OnLocalClientNoAssigned() path that flushes _pendingSelfClientNV into NetworkVariableManager. As a result, any SetClientVariable() calls made before the offline “connection” is established will remain queued forever. Consider reusing OnLocalClientNoAssigned(1) (or factoring the flush logic into a shared helper) instead of setting _clientNo directly.
| _clientNo = 1; | |
| _networkVariableManager?.MarkInitialSyncComplete(); | |
| _shouldCheckReady = true; | |
| DebugLog("Offline mode: client number set to 1, initial sync marked complete"); | |
| // Use the same path as online mode for assigning the local client number | |
| // so that any pending self client network variables are flushed. | |
| OnLocalClientNoAssigned(1); | |
| _networkVariableManager?.MarkInitialSyncComplete(); | |
| _shouldCheckReady = true; | |
| DebugLog("Offline mode: client number set to 1 via OnLocalClientNoAssigned, initial sync marked complete"); |
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs
Show resolved
Hide resolved
|
@claude Review the latest code. |
|
Claude finished @from2001's task in 1m 29s —— View job Code Review Complete ✓
SummaryOverall, this is a well-structured implementation that successfully introduces offline mode functionality to NetSync. The abstraction via Critical Issues1. Pending Self Client Variables Not Flushed in Offline Mode
|

This pull request introduces a new "offline mode" to the NetSync system, allowing the network synchronization components to operate without a server for local testing. This is achieved by introducing an
IConnectionManagerinterface, anOfflineConnectionManagerimplementation, and updating the core managers to support this abstraction. The changes also include logic to handle variable and RPC synchronization locally in offline mode, and expose a new option in the Unity inspector.Offline Mode and Connection Abstraction:
IConnectionManagerinterface to abstract network connection management, and refactored all network-related managers (NetworkVariableManager,RPCManager,TransformSyncManager, andNetSyncManager) to depend on this interface instead of the concreteConnectionManagerclass.OfflineConnectionManager, a no-op implementation ofIConnectionManagerfor use in offline mode, allowing the system to simulate a connection without a server.NetSyncManagerto select betweenConnectionManagerandOfflineConnectionManagerbased on a new_offlineModeserialized field, and to exposeIsOfflineModefor use by other components.Offline Mode Logic in Managers:
NetworkVariableManagerandRPCManagerto handle variable changes and RPC calls locally (without network round-trips) when in offline mode, ensuring correct event firing and state updates.MarkInitialSyncComplete()toNetworkVariableManagerand logic inNetSyncManagerto immediately assign a client number and complete initial sync in offline mode.Editor and Inspector Improvements:
_offlineModeoption in the Unity inspector and updated the editor property order to include it, allowing users to enable offline mode for testing.These changes make it possible to test and use NetSync features locally without requiring a server, greatly improving development workflow and testability.