diff --git a/BoneSync/Sync/Components/SyncableBase.cs b/BoneSync/Sync/Components/SyncableBase.cs index 684ebeb..640d108 100644 --- a/BoneSync/Sync/Components/SyncableBase.cs +++ b/BoneSync/Sync/Components/SyncableBase.cs @@ -61,9 +61,9 @@ namespace BoneSync.Sync.Components { public const int OBJECT_SYNC_FPS = 20; - public static Dictionary syncablesCache = new Dictionary(); + public static Dictionary syncablesCache = new Dictionary(); public Syncable(IntPtr intPtr) : base(intPtr) { - syncablesCache[gameObject] = this; + syncablesCache[gameObject.GetHashCode()] = this; } private bool _syncCoroutineRunning; @@ -166,7 +166,7 @@ namespace BoneSync.Sync.Components public void OnEnable() { - syncablesCache[gameObject] = this; + syncablesCache[gameObject.GetHashCode()] = this; FindAndUpdateComponents(); @@ -321,7 +321,7 @@ namespace BoneSync.Sync.Components } - if (gameObject) syncablesCache.Remove(gameObject); + if (gameObject) syncablesCache.Remove(gameObject.GetHashCode()); ObjectSyncCache.RemoveSyncable(this); diff --git a/BoneSync/Sync/ObjectSync.cs b/BoneSync/Sync/ObjectSync.cs index 6605577..b370e14 100644 --- a/BoneSync/Sync/ObjectSync.cs +++ b/BoneSync/Sync/ObjectSync.cs @@ -154,7 +154,7 @@ namespace BoneSync.Sync private static Syncable _GetSyncableFromCache(GameObject gameObject) { - bool success = Syncable.syncablesCache.TryGetValue(gameObject, out Syncable syncable); + bool success = Syncable.syncablesCache.TryGetValue(gameObject.GetHashCode(), out Syncable syncable); if (!success) { return null; @@ -173,7 +173,7 @@ namespace BoneSync.Sync } public static Syncable MakeOrGetSyncable(GameObject gameObject) { - Syncable syncable = _GetSyncableFromCache(gameObject); // buttons must never be a sub syncable + Syncable syncable = _GetSyncableFromCache(gameObject); if (syncable == null) { syncable = _MakeOrGetSyncable(gameObject);