Skip to content

Commit

Permalink
fix: updating syncObject ReadOnly before StartServer/Client
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Frowen committed Aug 2, 2023
1 parent b96ed68 commit 67a1d06
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Assets/Mirage/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,11 @@ internal void StartServer()
{
if (logger.LogEnabled()) logger.Log($"OnStartServer invoked on '{this}' (NetId: {NetId}, SceneId: {SceneId:X})");

// update sync direction before invoking start callback
// need to do this because IsServer might now be set when it previosuly wasn't
foreach (var comp in NetworkBehaviours)
comp.UpdateSyncObjectShouldSync();

_onStartServer.Invoke();
}

Expand All @@ -547,8 +552,13 @@ internal void StartClient()
{
if (_clientStarted)
return;
_clientStarted = true;

// update sync direction before invoking start callback
// need to do this because IsClient/Owner might now be set when it previosuly wasn't
foreach (var comp in NetworkBehaviours)
comp.UpdateSyncObjectShouldSync();

_clientStarted = true;
_onStartClient.Invoke();
}

Expand Down

0 comments on commit 67a1d06

Please sign in to comment.