Class GameObjectPool
UnityEngine.GameObject based functionality extending the SimpleListManagedPool to better support UnityEngine.GameObject patterns.
Inheritance
Namespace: GDX.Collections.Pooling
Syntax
[VisualScriptingCompatible((short)1)]
public static class GameObjectPool
Methods
| Improve this Doc View SourceCreatePool(GameObject, Transform, Int32, Int32, Boolean, Boolean, Boolean)
Create a UnityEngine.GameObject based SimpleListManagedPool for the provided
gameObject
.
Declaration
public static IManagedPool CreatePool(GameObject gameObject, Transform parent, int minimumObjects = 10, int maximumObjects = 50, bool allowCreateMore = true, bool allowReuseWhenCapped = false, bool allowManagedTearDown = false)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | gameObject | The object which going to be cloned. |
UnityEngine.Transform | parent | The container object. |
System.Int32 | minimumObjects | The minimum number of objects to be pooled. |
System.Int32 | maximumObjects | The maximum number of objects to be pooled. |
System.Boolean | allowCreateMore | Can more items be created as needed when starved for items? |
System.Boolean | allowReuseWhenCapped | Should we reuse oldest items when starving for items? |
System.Boolean | allowManagedTearDown | Does the pool allow a managed tear down event call? |
Returns
Type | Description |
---|---|
IManagedPool |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Boolean)
Get the next available item from the pool
.
Declaration
public static GameObject Get(SimpleListManagedPool pool, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Transform, Boolean, Boolean, Boolean)
Get the next available item from the pool
and parent it to a UnityEngine.Transform.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Transform parent, bool worldPositionStays = false, bool zeroLocalPosition = true, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Transform | parent | The transform parent on the item pulled from the SimpleListManagedPool. |
System.Boolean | worldPositionStays | Ensure that the world position of the item pulled from the SimpleListManagedPool remains the same through parenting. |
System.Boolean | zeroLocalPosition | Set the local position of the item pulled from the SimpleListManagedPool to being UnityEngine.Vector3.zero after parenting. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Transform, Vector3, Quaternion, Boolean)
Get the next available item from the pool
, parent it to a UnityEngine.Transform, and then
set it's local position and rotation.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Transform parent, Vector3 localPosition, Quaternion localRotation, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Transform | parent | The transform parent on the item pulled from the SimpleListManagedPool. |
UnityEngine.Vector3 | localPosition | The local position to set on the item pulled from the SimpleListManagedPool after parenting. |
UnityEngine.Quaternion | localRotation | The local rotation to set on the item pulled from the SimpleListManagedPool after parenting. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Transform, Vector3, Vector3, Boolean)
Get the next available item from the pool
, parent it to a UnityEngine.Transform, and then
setting it's local position and where it is looking.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Transform parent, Vector3 localPosition, Vector3 worldLookAtPosition, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Transform | parent | The transform parent on the item pulled from the SimpleListManagedPool. |
UnityEngine.Vector3 | localPosition | The local position to set on the item pulled from the SimpleListManagedPool after parenting. |
UnityEngine.Vector3 | worldLookAtPosition | The world position to have the item pulled from the SimpleListManagedPool look at |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Vector3, Quaternion, Boolean)
Get the next available item from the pool
, and set its world position and rotation.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Vector3 worldPosition, Quaternion worldRotation, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Vector3 | worldPosition | The world position to set on the item pulled from the SimpleListManagedPool. |
UnityEngine.Quaternion | worldRotation | The world rotation to set on the item pulled from the SimpleListManagedPool. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Vector3, Quaternion, Transform, Boolean)
Get the next available item from the pool
, and set its world position and rotation after
parenting.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Vector3 worldPosition, Quaternion worldRotation, Transform parent, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Vector3 | worldPosition | The world position to set on the item pulled from the SimpleListManagedPool after parenting. |
UnityEngine.Quaternion | worldRotation | The world rotation to set on the item pulled from the SimpleListManagedPool after parenting. |
UnityEngine.Transform | parent | The transform parent on the item pulled from the SimpleListManagedPool. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Vector3, Vector3, Boolean)
Get the next available item from the pool
, and set its world position and where it is looking.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Vector3 worldPosition, Vector3 worldLookAtPosition, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Vector3 | worldPosition | The world position to set on the item pulled from the SimpleListManagedPool. |
UnityEngine.Vector3 | worldLookAtPosition | The world position to have the item pulled from the SimpleListManagedPool look at |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
Get(SimpleListManagedPool, Vector3, Vector3, Transform, Boolean)
Get the next available item from the pool
, and set its world position and look at position
after parenting.
Declaration
public static GameObject Get(SimpleListManagedPool pool, Vector3 worldPosition, Vector3 worldLookAtPosition, Transform parent, bool triggerOnSpawnedFromPool = true)
Parameters
Type | Name | Description |
---|---|---|
SimpleListManagedPool | pool | The SimpleListManagedPool created with GameObjectPool to pull an item from. |
UnityEngine.Vector3 | worldPosition | The world position to set on the item pulled from the SimpleListManagedPool after parenting. |
UnityEngine.Vector3 | worldLookAtPosition | The world position to have the item pulled from the SimpleListManagedPool look at after parenting. |
UnityEngine.Transform | parent | The transform parent on the item pulled from the SimpleListManagedPool. |
System.Boolean | triggerOnSpawnedFromPool | Should the GDX.Collections.Pooling.GameObjectPool.OnSpawnedFromPoolAction(GDX.Collections.Pooling.SimpleListManagedPool,System.Object) be called when getting this item. |
Returns
Type | Description |
---|---|
UnityEngine.GameObject | A UnityEngine.GameObject from the SimpleListManagedPool, or null if no item is available. |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |
GetOrCreatePool(GameObject, Transform, Int32, Int32, Boolean, Boolean, Boolean)
Gets a pool for the gameObject
, or creates a new SimpleListManagedPool for it.
Declaration
public static IManagedPool GetOrCreatePool(GameObject gameObject, Transform parent, int minimumObjects = 10, int maximumObjects = 50, bool allowCreateMore = true, bool allowReuseWhenCapped = false, bool allowManagedTearDown = false)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | gameObject | The object which going to be cloned. |
UnityEngine.Transform | parent | The container object. |
System.Int32 | minimumObjects | The minimum number of objects to be pooled. |
System.Int32 | maximumObjects | The maximum number of objects to be pooled. |
System.Boolean | allowCreateMore | Can more items be created as needed when starved for items? |
System.Boolean | allowReuseWhenCapped | Should we reuse oldest items when starving for items? |
System.Boolean | allowManagedTearDown | Does the pool allow a managed tear down event call? |
Returns
Type | Description |
---|---|
IManagedPool |
Exceptions
Type | Condition |
---|---|
UnsupportedRuntimeException | Not supported on DOTS Runtime. |