File tree 1 file changed +9
-8
lines changed
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) =>
61
61
instance . ReturnToPool ( ) ;
62
62
63
63
/// <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
65
65
/// </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 > ( ) ;
68
69
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
+ }
74
75
}
75
76
}
You can’t perform that action at this time.
0 commit comments