File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 11#if ODIN_INSPECTOR
22using Sirenix . OdinInspector ;
3+ using System . Collections . Generic ;
34#endif
45using 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}
You can’t perform that action at this time.
0 commit comments