diff --git a/Assets/Mirror/Core/NetworkBehaviour.cs b/Assets/Mirror/Core/NetworkBehaviour.cs index 00a01667d..e23c562e8 100644 --- a/Assets/Mirror/Core/NetworkBehaviour.cs +++ b/Assets/Mirror/Core/NetworkBehaviour.cs @@ -1260,7 +1260,7 @@ internal void DeserializeObjectsDelta(NetworkReader reader) // on other entities would be mismatched, causing the weirdest errors. // // reads <> for 100% safety. - internal void Serialize(NetworkWriter writer, bool initialState) + internal void Serialize(NetworkWriter writer, bool initialState, SyncMethod method) { // reserve length header to ensure the correct amount will be read. // originally we used a 4 byte header (too bandwidth heavy). @@ -1288,8 +1288,12 @@ internal void Serialize(NetworkWriter writer, bool initialState) // write payload try { - // note this may not write anything if no syncIntervals elapsed - OnSerialize(writer, initialState); + // SyncMethod support: + // Traditional: Serialize(initial) once, then Serialize(delta) all the time. + // FastPaced: Serialize(initial) all the time because we always need full state for unreliable messages + // => reusing OnSerialize(initial=true) for FastPaced allows us to keep the API clean and simple. + // this way the end user never needs to worry about SyncMethod serialization. + OnSerialize(writer, initialState || method == SyncMethod.FastPaced); } catch (Exception e) { diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index e8fb3ff7b..f1e790b32 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -997,12 +997,7 @@ internal void SerializeServer(bool initialState, SyncMethod method, NetworkWrite // serialize into helper writer using (NetworkWriterPooled temp = NetworkWriterPool.Get()) { - // SyncMethod support: - // Traditional: Serialize(initial) once, then Serialize(delta) all the time. - // FastPaced: Serialize(initial) all the time because we always need full state for unreliable messages - // => reusing OnSerialize(initial=true) for FastPaced allows us to keep the API clean and simple. - // this way the end user never needs to worry about SyncMethod serialization. - comp.Serialize(temp, initialState || method == SyncMethod.FastPaced); + comp.Serialize(temp, initialState, method); ArraySegment segment = temp.ToArraySegment(); // copy to owner / observers as needed @@ -1072,14 +1067,7 @@ internal void SerializeClient(SyncMethod method, NetworkWriter writer) { // serialize into writer. // server always knows initialState, we never need to send it - - - // SyncMethod support: - // Traditional: always Serialize(delta) on client since server knows initial state. - // FastPaced: always Serialize(initial) on client since we need full state for unreliable sync. - // => reusing OnSerialize(initial=true) for FastPaced allows us to keep the API clean and simple. - // this way the end user never needs to worry about SyncMethod serialization. - comp.Serialize(writer, method == SyncMethod.FastPaced); + comp.Serialize(writer, false, method); // clear dirty bits for the components that we serialized. // do not clear for _all_ components, only the ones that