From 90ee471bb87bee4e81fe87ac7f6bcb2e056e1632 Mon Sep 17 00:00:00 2001 From: vis2k Date: Thu, 6 Jan 2022 12:25:13 +0800 Subject: [PATCH] simplify OnSerialize --- Assets/Mirror/Runtime/NetworkBehaviour.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 0b697acf8..49f1d00da 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -574,20 +574,10 @@ protected void SetSyncVar(T value, ref T fieldValue, ulong dirtyBit) // note: SyncVar hooks are only called when inital=false public virtual bool OnSerialize(NetworkWriter writer, bool initialState) { - bool objectWritten = false; // if initialState: write all SyncVars. // otherwise write dirtyBits+dirty SyncVars - if (initialState) - { - objectWritten = SerializeObjectsAll(writer); - } - else - { - objectWritten = SerializeObjectsDelta(writer); - } - + bool objectWritten = initialState ? SerializeObjectsAll(writer) : SerializeObjectsDelta(writer); bool syncVarWritten = SerializeSyncVars(writer, initialState); - return objectWritten || syncVarWritten; }