feat: spawning particles with object pooling
This commit is contained in:
parent
858e49e1d9
commit
efac0019ba
14 changed files with 235 additions and 21 deletions
39
Assets/Scripts/Pooling/PoolerExtensions.cs
Normal file
39
Assets/Scripts/Pooling/PoolerExtensions.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Pooling {
|
||||
public static class PoolerExtensions {
|
||||
public static void CreatePool<T>(this T prefab) where T : Component =>
|
||||
Pooler.CreatePool(prefab, 0);
|
||||
public static void CreatePool<T>(this T prefab, int initialPoolSize) where T : Component =>
|
||||
Pooler.CreatePool(prefab, initialPoolSize);
|
||||
public static void CreatePool(this GameObject prefab) =>
|
||||
Pooler.CreatePool(prefab, 0);
|
||||
public static void CreatePool(this GameObject prefab, int initialPoolSize) =>
|
||||
Pooler.CreatePool(prefab, initialPoolSize);
|
||||
|
||||
public static T Spawn<T>(this T prefab, Transform parent, Vector3 position, Quaternion rotation) where T : Component =>
|
||||
Pooler.Spawn(prefab, parent, position, rotation);
|
||||
public static T Spawn<T>(this T prefab, Vector3 position, Quaternion rotation) where T : Component =>
|
||||
Pooler.Spawn(prefab, null, position, rotation);
|
||||
public static T Spawn<T>(this T prefab, Transform parent, Vector3 position) where T : Component =>
|
||||
Pooler.Spawn(prefab, parent, position, Quaternion.identity);
|
||||
public static T Spawn<T>(this T prefab, Vector3 position) where T : Component =>
|
||||
Pooler.Spawn(prefab, null, position, Quaternion.identity);
|
||||
public static T Spawn<T>(this T prefab, Transform parent) where T : Component =>
|
||||
Pooler.Spawn(prefab, parent, Vector3.zero, Quaternion.identity);
|
||||
public static T Spawn<T>(this T prefab) where T : Component =>
|
||||
Pooler.Spawn(prefab, null, Vector3.zero, Quaternion.identity);
|
||||
public static GameObject Spawn(this GameObject prefab, Transform parent, Vector3 position, Quaternion rotation) =>
|
||||
Pooler.Spawn(prefab, parent, position, rotation);
|
||||
public static GameObject Spawn(this GameObject prefab, Vector3 position, Quaternion rotation) =>
|
||||
Pooler.Spawn(prefab, null, position, rotation);
|
||||
public static GameObject Spawn(this GameObject prefab, Transform parent, Vector3 position) =>
|
||||
Pooler.Spawn(prefab, parent, position, Quaternion.identity);
|
||||
public static GameObject Spawn(this GameObject prefab, Vector3 position) =>
|
||||
Pooler.Spawn(prefab, null, position, Quaternion.identity);
|
||||
public static GameObject Spawn(this GameObject prefab, Transform parent) =>
|
||||
Pooler.Spawn(prefab, parent, Vector3.zero, Quaternion.identity);
|
||||
public static GameObject Spawn(this GameObject prefab) =>
|
||||
Pooler.Spawn(prefab, null, Vector3.zero, Quaternion.identity);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue