Skip to content

Commit dfd245f

Browse files
authored
Update Poolable.cs
1 parent 6ebe78c commit dfd245f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Runtime/Poolable.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if ODIN_INSPECTOR
22
using Sirenix.OdinInspector;
3+
using System.Collections.Generic;
34
#endif
45
using UnityEngine;
56

@@ -14,6 +15,8 @@ public class Poolable : MonoBehaviour
1415
private IPoolable[] _poolables = new IPoolable[0];
1516
private bool _isEnabled = false;
1617

18+
private static HashSet<int> _pooledObjects = new HashSet<int>();
19+
1720
private void Awake() =>
1821
_poolables = GetComponentsInChildren<IPoolable>(true);
1922

@@ -46,7 +49,11 @@ public void SetPool(Pool pool)
4649
{
4750
Pool = pool;
4851
IsPooled = true;
52+
_pooledObjects.Add(gameObject.GetHashCode());
4953
}
5054
}
55+
56+
public static bool IsInstancePooled(GameObject instance) =>
57+
_pooledObjects.Contains(instance.GetHashCode());
5158
}
5259
}

0 commit comments

Comments
 (0)