From 0ffa3169a479e516e838365127900cbc15bb59ec Mon Sep 17 00:00:00 2001 From: James Frowen Date: Tue, 7 May 2024 00:17:08 +0100 Subject: [PATCH] fix: fixing initial send to observers if from server is false 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 --- Assets/Mirage/Runtime/NetworkIdentity.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/Assets/Mirage/Runtime/NetworkIdentity.cs b/Assets/Mirage/Runtime/NetworkIdentity.cs index bf50891511..8f124fed97 100644 --- a/Assets/Mirage/Runtime/NetworkIdentity.cs +++ b/Assets/Mirage/Runtime/NetworkIdentity.cs @@ -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}'");