@@ -10,10 +10,10 @@ internal sealed class Pool
1010 private readonly Quaternion _rotation = default ;
1111 private readonly Vector3 _scale = default ;
1212
13- private static readonly Dictionary < int , Pool > _prefabLookup = new Dictionary < int , Pool > ( 100 ) ;
14- private static readonly Dictionary < int , Pool > _instanceLookup = new Dictionary < int , Pool > ( 10000 ) ;
13+ private static readonly Dictionary < GameObject , Pool > _prefabLookup = new Dictionary < GameObject , Pool > ( 64 ) ;
14+ private static readonly Dictionary < GameObject , Pool > _instanceLookup = new Dictionary < GameObject , Pool > ( 512 ) ;
1515
16- private const int CAPACITY = 100 ;
16+ private const int CAPACITY = 128 ;
1717
1818 public Pool ( GameObject prefab )
1919 {
@@ -27,7 +27,7 @@ public Pool(GameObject prefab)
2727 }
2828
2929 _instances = new Stack < Poolable > ( CAPACITY ) ;
30- _prefabLookup . Add ( prefab . GetHashCode ( ) , this ) ;
30+ _prefabLookup . Add ( prefab , this ) ;
3131
3232 var transform = prefab . transform ;
3333 _rotation = transform . rotation ;
@@ -36,7 +36,7 @@ public Pool(GameObject prefab)
3636
3737 public static Pool GetPrefabPool ( GameObject prefab )
3838 {
39- bool hasPool = _prefabLookup . TryGetValue ( prefab . GetHashCode ( ) , out var pool ) ;
39+ bool hasPool = _prefabLookup . TryGetValue ( prefab , out var pool ) ;
4040
4141 if ( ! hasPool )
4242 pool = new Pool ( prefab ) ;
@@ -45,7 +45,7 @@ public static Pool GetPrefabPool(GameObject prefab)
4545 }
4646
4747 public static bool TryGetInstancePool ( GameObject instance , out Pool pool ) =>
48- _instanceLookup . TryGetValue ( instance . GetHashCode ( ) , out pool ) ;
48+ _instanceLookup . TryGetValue ( instance , out pool ) ;
4949
5050 public void Populate ( int count )
5151 {
@@ -165,7 +165,7 @@ private Poolable GetInstance()
165165 private Poolable CreateInstance ( )
166166 {
167167 var instance = Object . Instantiate ( _prefab ) ;
168- _instanceLookup . Add ( instance . gameObject . GetHashCode ( ) , this ) ;
168+ _instanceLookup . Add ( instance . gameObject , this ) ;
169169
170170 return instance ;
171171 }
0 commit comments