DoopelPonger
|
Class used to hold and dish out allocated objects. More...
Classes | |
class | IObjectPoolerItem |
Any object that implements this interface can be pooled in the object pooler. More... | |
Public Member Functions | |
void | Awake () |
Initialize data structures to store the unused objects. More... | |
T | GetObjectFromCustomKeyPool< T > (T poolItem) |
Takes the first item off the unusues queue or creates a new object of type T. More... | |
void | ReturnObjectToCustomKeyPool< T > (T returnObject) |
Takes the IObjectPoolerItem, deactivates it, and places it in the unused queue. More... | |
void | PreAllocatePool< T > (T original, int copies) |
Given the prefab original object, pre store unused copies of objects in the queue. More... | |
T | GetMonoBehaviour< T > (T original, int numberToPreAllocate) |
Get the MonoBehaviour from the unused queue. If the queue never existed, create one with the size requested. More... | |
T [] | GetMonoBehaviour< T > (T[] originals) |
Iterate through the list of MonoBehaviours and get/create an instance from the appropirate unused queue. More... | |
T | GetMonoBehaviour< T > (T original) |
Get the MonoBehaviour from the unused queue. More... | |
ScriptableObject | GetScriptableObject (System.Type scriptableType) |
Get the ScriptableObject from the unused queue. More... | |
T | GetScriptableObject< T > () |
Get the ScriptableObject from the unused queue. More... | |
T | GetObject< T > (T original) |
Get the Unity Object from the unused queue. More... | |
void | ReturnObject< T > (T returnObject) |
void | ReturnMonoBehaviour< T > (T returnObject) |
void | ReturnScriptableObject< T > (T returnObject) |
Class used to hold and dish out allocated objects.
If the object being asked for does not exist, then one will be created and then returned. The original implementation of this object would save/return objects based on the System.Type. However this is not ideal in cases where the underlying object is the same but the properties of the object are different (like objects that hold audio information). So at the end of developement I added the IObjectPoolerItem interface so that similar objects could be pooled without getting their properties switched around.
void CoopObjectPooler.Awake | ( | ) |
Initialize data structures to store the unused objects.
T CoopObjectPooler.GetMonoBehaviour< T > | ( | T | original, |
int | numberToPreAllocate | ||
) |
Get the MonoBehaviour from the unused queue. If the queue never existed, create one with the size requested.
original | The object to be created/returned from the object pooler. |
numberToPreAllocate | How big the holding queue should be if it doesn't already exist for the original. |
T | : | MonoBehaviour |
T [] CoopObjectPooler.GetMonoBehaviour< T > | ( | T [] | originals | ) |
Iterate through the list of MonoBehaviours and get/create an instance from the appropirate unused queue.
originals | List of MonoBehaviours to return instances of. |
T | : | MonoBehaviour |
T CoopObjectPooler.GetMonoBehaviour< T > | ( | T | original | ) |
Get the MonoBehaviour from the unused queue.
original | The object to be created/returned from the object pooler. |
T | : | MonoBehaviour |
T CoopObjectPooler.GetObject< T > | ( | T | original | ) |
Get the Unity Object from the unused queue.
original | The object to be created/returned from the object pooler. |
T | : | Object |
T CoopObjectPooler.GetObjectFromCustomKeyPool< T > | ( | T | poolItem | ) |
Takes the first item off the unusues queue or creates a new object of type T.
poolItem | Prefab of the object that should be returned, must be of type IObjectPoolerItem so it finds the item to return by the GetObjectPoolerKey identifier. |
T | : | MonoBehaviour | |
T | : | IObjectPoolerItem |
ScriptableObject CoopObjectPooler.GetScriptableObject | ( | System.Type | scriptableType | ) |
Get the ScriptableObject from the unused queue.
scriptableType | The type of the ScriptableObject to return |
T CoopObjectPooler.GetScriptableObject< T > | ( | ) |
Get the ScriptableObject from the unused queue.
T | The type of the ScriptableObject to return |
T | : | ScriptableObject |
void CoopObjectPooler.PreAllocatePool< T > | ( | T | original, |
int | copies | ||
) |
Given the prefab original object, pre store unused copies of objects in the queue.
original | Blueprint object that will be created and placed in the unused pool. |
copies | Number of new objects placed unused pool. |
T | : | MonoBehaviour |
void CoopObjectPooler.ReturnMonoBehaviour< T > | ( | T | returnObject | ) |
returnedObject | MonoBehaviour to set unactive and place back into the unused queue. |
T | : | MonoBehaviour |
void CoopObjectPooler.ReturnObject< T > | ( | T | returnObject | ) |
returnObject | Unity Object to place back into the unusused queue. |
T | : | Object |
void CoopObjectPooler.ReturnObjectToCustomKeyPool< T > | ( | T | returnObject | ) |
Takes the IObjectPoolerItem, deactivates it, and places it in the unused queue.
returnObject | GameObject that should be deactived and placed in the unused queue. |
T | : | MonoBehaviour | |
T | : | IObjectPoolerItem |
void CoopObjectPooler.ReturnScriptableObject< T > | ( | T | returnObject | ) |
returnObject | ScriptableObject to be placed back in the unused queue. |
T | : | ScriptableObject |