Show / Hide Table of Contents

    Class MasterObjectPooler

    MasterObjectPooler manages various ObjectPools. By using a MasterObjectPooler, you can perform a large variety of pool operations with a named string reference instead of requiring an object reference to the ObjectPool. Furthermore, initialization of the pools is handled by the MOP. Pools can be added either via the inspector or at runtime.

    Inheritance
    Object
    UnityEngine.Object
    UnityEngine.Component
    UnityEngine.Behaviour
    UnityEngine.MonoBehaviour
    MasterObjectPooler
    Namespace: QFSW.MOP2
    Assembly: QFSW.MOP2.dll
    Syntax
    public class MasterObjectPooler : MonoBehaviour

    Properties

    | Improve this Doc View Source

    Instance

    Singleton reference to the MOP. Only valid and set if the singleton option is enabled for the MOP.

    Declaration
    public static MasterObjectPooler Instance { get; }
    Property Value
    Type Description
    MasterObjectPooler
    | Improve this Doc View Source

    Item[String]

    Retrieves/adds a pool.

    Declaration
    public ObjectPool this[string poolName] { get; set; }
    Parameters
    Type Name Description
    String poolName

    The name of the pool to retrieve/add.

    Property Value
    Type Description
    ObjectPool

    The retrieved pool.

    Methods

    | Improve this Doc View Source

    AddPool(ObjectPool)

    Adds an ObjectPool to the MasterObjectPooler and initializes it.

    Declaration
    public void AddPool(ObjectPool pool)
    Parameters
    Type Name Description
    ObjectPool pool

    The ObjectPool to add to the MasterObjectPooler.

    | Improve this Doc View Source

    AddPool(String, ObjectPool)

    Adds an ObjectPool to the MasterObjectPooler and initializes it.

    Declaration
    public void AddPool(string poolName, ObjectPool pool)
    Parameters
    Type Name Description
    String poolName

    Override for the named string reference to use for this pool. By default uses the ObjectPool's name.

    ObjectPool pool

    The ObjectPool to add to the MasterObjectPooler.

    | Improve this Doc View Source

    Destroy(IEnumerable<GameObject>, String)

    Forcibly destroys a collection of objects and does not return them to a pool.

    Declaration
    public void Destroy(IEnumerable<GameObject> objs, string poolName)
    Parameters
    Type Name Description
    IEnumerable<UnityEngine.GameObject> objs

    The objects to destroy.

    String poolName

    The name of the pool that the objects belonged to.

    | Improve this Doc View Source

    Destroy(GameObject)

    Forcibly destroys the object and does not return it to a pool.

    Declaration
    public void Destroy(GameObject obj)
    Parameters
    Type Name Description
    UnityEngine.GameObject obj

    The object to destroy.

    | Improve this Doc View Source

    Destroy(GameObject, String)

    Forcibly destroys the object and does not return it to a pool.

    Declaration
    public void Destroy(GameObject obj, string poolName)
    Parameters
    Type Name Description
    UnityEngine.GameObject obj

    The object to destroy.

    String poolName

    The name of the pool that the object belonged to.

    | Improve this Doc View Source

    DestroyAllPools()

    Destroys every pool, purging all of their contents then removing them from the MasterObjectPooler.

    Declaration
    public void DestroyAllPools()
    | Improve this Doc View Source

    DestroyPool(String)

    Destroys a specified pool, purging its contents and removing it from the MasterObjectPooler.

    Declaration
    public void DestroyPool(string poolName)
    Parameters
    Type Name Description
    String poolName

    The pool to destroy.

    | Improve this Doc View Source

    GetAllActiveObjects(String)

    Gets all active objects in the specified pool.

    Declaration
    public IEnumerable<GameObject> GetAllActiveObjects(string poolName)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to populate.

    Returns
    Type Description
    IEnumerable<UnityEngine.GameObject>

    The active objects.

    | Improve this Doc View Source

    GetObject(String)

    Gets an object from the specified pool.

    Declaration
    public GameObject GetObject(string poolName)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get an object from.

    Returns
    Type Description
    UnityEngine.GameObject

    The retrieved object.

    | Improve this Doc View Source

    GetObject(String, Vector3)

    Gets an object from the specified pool.

    Declaration
    public GameObject GetObject(string poolName, Vector3 position)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get an object from.

    UnityEngine.Vector3 position

    The position to set the object to.

    Returns
    Type Description
    UnityEngine.GameObject

    The retrieved object.

    | Improve this Doc View Source

    GetObject(String, Vector3, Quaternion)

    Gets an object from the specified pool.

    Declaration
    public GameObject GetObject(string poolName, Vector3 position, Quaternion rotation)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get an object from.

    UnityEngine.Vector3 position

    The position to set the object to.

    UnityEngine.Quaternion rotation

    The rotation to set the object to.

    Returns
    Type Description
    UnityEngine.GameObject

    The retrieved object.

    | Improve this Doc View Source

    GetObjectComponent<T>(String)

    Gets an object from the specified pool, and then retrieves the specified component using a cache to improve performance. Note: this should not be used if multiple components of the same type exist on the object, or if the component will be dynamically removed/added at runtime.

    Declaration
    public T GetObjectComponent<T>(string poolName)
        where T : class
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get the component from.

    Returns
    Type Description
    T

    The retrieved component.

    Type Parameters
    Name Description
    T

    The component type to get.

    | Improve this Doc View Source

    GetObjectComponent<T>(String, Vector3)

    Gets an object from the specified pool, and then retrieves the specified component using a cache to improve performance. Note: this should not be used if multiple components of the same type exist on the object, or if the component will be dynamically removed/added at runtime.

    Declaration
    public T GetObjectComponent<T>(string poolName, Vector3 position)
        where T : class
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get the component from.

    UnityEngine.Vector3 position

    The position to set the object to.

    Returns
    Type Description
    T

    The retrieved component.

    Type Parameters
    Name Description
    T

    The component type to get.

    | Improve this Doc View Source

    GetObjectComponent<T>(String, Vector3, Quaternion)

    Gets an object from the specified pool, and then retrieves the specified component using a cache to improve performance. Note: this should not be used if multiple components of the same type exist on the object, or if the component will be dynamically removed/added at runtime.

    Declaration
    public T GetObjectComponent<T>(string poolName, Vector3 position, Quaternion rotation)
        where T : class
    Parameters
    Type Name Description
    String poolName

    The name of the pool to get the component from.

    UnityEngine.Vector3 position

    The position to set the object to.

    UnityEngine.Quaternion rotation

    The rotation to set the object to.

    Returns
    Type Description
    T

    The retrieved component.

    Type Parameters
    Name Description
    T

    The component type to get.

    | Improve this Doc View Source

    GetPool(String)

    Retrieves a pool.

    Declaration
    public ObjectPool GetPool(string poolName)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to retrieve.

    Returns
    Type Description
    ObjectPool

    The retrieved pool.

    | Improve this Doc View Source

    Populate(String, Int32, PopulateMethod)

    Populates the specified pool with the specified number of objects, so that they do not need instantiating later.

    Declaration
    public void Populate(string poolName, int quantity, PopulateMethod method = PopulateMethod.Set)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to populate.

    Int32 quantity

    The number of objects to populate it with.

    PopulateMethod method

    The population mode.

    | Improve this Doc View Source

    Purge(String)

    Destroys every object in the specified pool, both alive and pooled.

    Declaration
    public void Purge(string poolName)
    Parameters
    Type Name Description
    String poolName

    The name of the pool to populate.

    | Improve this Doc View Source

    PurgeAll()

    Destroys every object in every pool, both alive and pooled.

    Declaration
    public void PurgeAll()
    | Improve this Doc View Source

    Release(IEnumerable<GameObject>, String)

    Releases a collection of objects and returns them back to the specified pool, effectively 'destroying' them from the scene.

    Declaration
    public void Release(IEnumerable<GameObject> objs, string poolName)
    Parameters
    Type Name Description
    IEnumerable<UnityEngine.GameObject> objs

    the objects to release.

    String poolName

    The name of the pool to return the objects to.

    | Improve this Doc View Source

    Release(GameObject, String)

    Releases an object and returns it back to the specified pool, effectively 'destroying' it from the scene. Pool equivalent of Destroy.

    Declaration
    public void Release(GameObject obj, string poolName)
    Parameters
    Type Name Description
    UnityEngine.GameObject obj

    The object to release.

    String poolName

    The name of the pool to return the object to.

    | Improve this Doc View Source

    ReleaseAll(String)

    Releases every active object in the specified pool.

    Declaration
    public void ReleaseAll(string poolName)
    Parameters
    Type Name Description
    String poolName

    The name of the pool.

    | Improve this Doc View Source

    ReleaseAllInAllPools()

    Releases every active object in every pool.

    Declaration
    public void ReleaseAllInAllPools()
    • Improve this Doc
    • View Source
    Master Object Pooler 2 by QFSW
    Back to top