Table of Contents

Class SwiftGameObjectPoolAsset

A ScriptableObject that manages multiple SwiftGameObjectPool instances.

[CreateAssetMenu(menuName = "SwiftCollections/SwiftGameObjectPoolAsset", fileName = "SwiftGameObjectPoolAsset")]
public class SwiftGameObjectPoolAsset : ScriptableObject, IDisposable
Inheritance
Object
ScriptableObject
SwiftGameObjectPoolAsset
Implements
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Constructors

SwiftGameObjectPoolAsset(SwiftGameObjectPool[])

Initializes an asset with the supplied pool definitions.

public SwiftGameObjectPoolAsset(SwiftGameObjectPool[] pools)

Parameters

pools SwiftGameObjectPool[]

The pool definitions managed by the asset.

Properties

ParentTransform

Gets the persistent root transform created by Init().

public Transform ParentTransform { get; }

Property Value

Transform

Methods

Dispose()

Disposes all pools and their resources.

public void Dispose()

GetObject(string)

Gets an object from the specified pool by ID.

public GameObject GetObject(string id)

Parameters

id string

The pool name.

Returns

GameObject

A pooled GameObject instance.

Exceptions

ArgumentException

id is null, empty, or whitespace.

InvalidOperationException

The pool configuration is invalid, the pool is missing, or it is exhausted.

Init()

Initializes the object pool asset, creating the parent transform and prewarming pools as needed.

public void Init()

Exceptions

InvalidOperationException

The pool definitions are missing, invalid, or contain duplicate names.

ReleaseObject(string, GameObject)

Releases an object back into the specified pool.

public void ReleaseObject(string id, GameObject gameObject)

Parameters

id string

The pool name.

gameObject GameObject

The pooled instance to release.

Exceptions

ArgumentException

id is null, empty, or whitespace.

ArgumentNullException

gameObject is null.

InvalidOperationException

The pool is missing, invalid, or does not own the instance.

TryGetObject(string, out GameObject)

Attempts to get an object from the specified pool by ID without throwing when the pool is missing or exhausted.

public bool TryGetObject(string id, out GameObject gameObject)

Parameters

id string

The pool name.

gameObject GameObject

The pooled GameObject instance when successful.

Returns

bool

true when an object was acquired; otherwise false.

Exceptions

InvalidOperationException

The pool configuration is invalid.