Skip to content

Commit

Permalink
fix: fixing initial send to observers if from server is false
Browse files Browse the repository at this point in the history
Server should still send initial data to observers even if from server is false. this will give observers the data that owner has previously told server to relay to observers
  • Loading branch information
James-Frowen committed May 6, 2024
1 parent c1b1056 commit 0ffa316
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Assets/Mirage/Runtime/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,19 @@ private void OnSerialize(int i, NetworkBehaviour comp, NetworkWriter writer, boo
continue;

// check if we should be writing this components
if (!comp.SyncSettings.ShouldSyncFrom(this, false))
continue;

if (initialState)
{
// for initial, check if we are sending to either owner/observers, even if From.Server is false
var shouldSend = (comp.SyncSettings.To & SyncTo.OwnerAndObservers) != 0;
if (!shouldSend)
continue;
}
else
{
if (!comp.SyncSettings.ShouldSyncFrom(this, false))
continue;
}

if (logger.LogEnabled()) logger.Log($"OnSerializeAllSafely: '{name}', component '{comp.GetType()}', initial state: '{initialState}'");

Expand Down

0 comments on commit 0ffa316

Please sign in to comment.