diff --git a/Assets/Mirror/Runtime/NetworkBehaviour.cs b/Assets/Mirror/Runtime/NetworkBehaviour.cs index 6a3cc1525..9a002e9ee 100644 --- a/Assets/Mirror/Runtime/NetworkBehaviour.cs +++ b/Assets/Mirror/Runtime/NetworkBehaviour.cs @@ -28,8 +28,10 @@ public class NetworkBehaviour : MonoBehaviour protected ulong syncVarDirtyBits { get; private set; } protected bool syncVarHookGuard { get; set; } + [Obsolete("Use syncObjects instead.")] + protected List m_SyncObjects => syncObjects; // objects that can synchronize themselves, such as synclists - protected readonly List m_SyncObjects = new List(); + protected readonly List syncObjects = new List(); // NetworkIdentity component caching for easier access NetworkIdentity m_netIdentity; @@ -66,7 +68,7 @@ public int ComponentIndex // We collect all of them and we synchronize them with OnSerialize/OnDeserialize protected void InitSyncObject(SyncObject syncObject) { - m_SyncObjects.Add(syncObject); + syncObjects.Add(syncObject); } #region Commands @@ -427,9 +429,9 @@ public void ClearAllDirtyBits() // note: don't use List.ForEach here, this is a hot path // List.ForEach: 432b/frame // for: 231b/frame - for (int i = 0; i < m_SyncObjects.Count; ++i) + for (int i = 0; i < syncObjects.Count; ++i) { - m_SyncObjects[i].Flush(); + syncObjects[i].Flush(); } } @@ -438,9 +440,9 @@ bool AnySyncObjectDirty() // note: don't use Linq here. 1200 networked objects: // Linq: 187KB GC/frame;, 2.66ms time // for: 8KB GC/frame; 1.28ms time - for (int i = 0; i < m_SyncObjects.Count; ++i) + for (int i = 0; i < syncObjects.Count; ++i) { - if (m_SyncObjects[i].IsDirty) + if (syncObjects[i].IsDirty) { return true; } @@ -484,9 +486,9 @@ public virtual void OnDeserialize(NetworkReader reader, bool initialState) ulong DirtyObjectBits() { ulong dirtyObjects = 0; - for (int i = 0; i < m_SyncObjects.Count; i++) + for (int i = 0; i < syncObjects.Count; i++) { - SyncObject syncObject = m_SyncObjects[i]; + SyncObject syncObject = syncObjects[i]; if (syncObject.IsDirty) { dirtyObjects |= 1UL << i; @@ -498,9 +500,9 @@ ulong DirtyObjectBits() public bool SerializeObjectsAll(NetworkWriter writer) { bool dirty = false; - for (int i = 0; i < m_SyncObjects.Count; i++) + for (int i = 0; i < syncObjects.Count; i++) { - SyncObject syncObject = m_SyncObjects[i]; + SyncObject syncObject = syncObjects[i]; syncObject.OnSerializeAll(writer); dirty = true; } @@ -513,9 +515,9 @@ public bool SerializeObjectsDelta(NetworkWriter writer) // write the mask writer.WritePackedUInt64(DirtyObjectBits()); // serializable objects, such as synclists - for (int i = 0; i < m_SyncObjects.Count; i++) + for (int i = 0; i < syncObjects.Count; i++) { - SyncObject syncObject = m_SyncObjects[i]; + SyncObject syncObject = syncObjects[i]; if (syncObject.IsDirty) { syncObject.OnSerializeDelta(writer); @@ -527,9 +529,9 @@ public bool SerializeObjectsDelta(NetworkWriter writer) void DeSerializeObjectsAll(NetworkReader reader) { - for (int i = 0; i < m_SyncObjects.Count; i++) + for (int i = 0; i < syncObjects.Count; i++) { - SyncObject syncObject = m_SyncObjects[i]; + SyncObject syncObject = syncObjects[i]; syncObject.OnDeserializeAll(reader); } } @@ -537,9 +539,9 @@ void DeSerializeObjectsAll(NetworkReader reader) void DeSerializeObjectsDelta(NetworkReader reader) { ulong dirty = reader.ReadPackedUInt64(); - for (int i = 0; i < m_SyncObjects.Count; i++) + for (int i = 0; i < syncObjects.Count; i++) { - SyncObject syncObject = m_SyncObjects[i]; + SyncObject syncObject = syncObjects[i]; if ((dirty & (1UL << i)) != 0) { syncObject.OnDeserializeDelta(reader);