File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -61,15 +61,16 @@ public static void Despawn(this Poolable instance) =>
6161 instance . ReturnToPool ( ) ;
6262
6363 /// <summary>
64- /// Use this method only with Instances of Prefab
64+ /// Use this method only with Instances of Prefab. Slow in terms of perforamance, use Despawn with Poolable param instead
6565 /// </summary>
66- public static void Despawn ( this GameObject instance ) =>
67- instance . GetComponent < Poolable > ( ) . ReturnToPool ( ) ;
66+ public static void Despawn ( this GameObject instance )
67+ {
68+ var poolable = instance . GetComponent < Poolable > ( ) ;
6869
69- /// <summary>
70- /// Use this method only with Instances of Prefab
71- /// </summary>
72- public static void Despawn ( this Transform instance ) =>
73- instance . GetComponent < Poolable > ( ) . ReturnToPool ( ) ;
70+ if ( poolable != null )
71+ poolable . ReturnToPool ( ) ;
72+ else
73+ Object . Destroy ( instance ) ;
74+ }
7475 }
7576}
You can’t perform that action at this time.
0 commit comments