Hydrogen Framework  1.3.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
hObjectPool Class Reference

A drop in implementation of the Hydrogen.Core.ObjectPool. This simply makes the class an accessible singleton with some very simple additional functionality. More...

+ Inheritance diagram for hObjectPool:

Static Public Member Functions

static bool Exists ()
 Does an Object Pool already exist? More...
 

Public Attributes

bool Persistent = true
 Should this object pool survive scene switches? More...
 
- Public Attributes inherited from Hydrogen.Core.ObjectPool
bool CullExtras
 Should extra objects be culled when not in use? More...
 
float CullInterval = 3f
 How often should we look at culling extra objects. More...
 
bool HandleParticles = true
 Should particle systems be appropriately handled when despawning? More...
 
ObjectPoolCollection[] ObjectPools
 Our pooled object collections. More...
 
int PreloadAmount = 5
 The number of objects to preload in an Object Pool. More...
 
bool SlowMessage
 Should Unity's SendMessage be used. (OnSpawned, WaitToDespawn, OnDespawned) More...
 
bool SpawnMore = true
 Should additional objects be spawned as needed? More...
 
bool TrackObjects
 Should objects be tracked when they are spawned? More...
 

Protected Member Functions

override void Awake ()
 Unity's Awake Event More...
 
- Protected Member Functions inherited from Hydrogen.Core.ObjectPool
virtual void Update ()
 Unity's Update Event More...
 

Properties

static hObjectPool Instance [get]
 Gets the object pool instance, creating one if none is found. More...
 

Additional Inherited Members

- Public Member Functions inherited from Hydrogen.Core.ObjectPool
int Add (GameObject prefab)
 Add a Prefab or GameObject to the Object Pool. More...
 
int Add (GameObject prefab, int preloadAmount)
 Add a Prefab or GameObject to the Object Pool. More...
 
int Add (GameObject prefab, int preloadAmount, bool spawnMore, bool slowMessage, bool handleParticles, bool trackSpawned, bool cullExtras, float cullInterval)
 Add a Prefab or GameObject to the Object Pool. More...
 
int[] Add (GameObject[] prefabs)
 Add an array of Prefabs or GameObjects to the Object Pool. More...
 
int[] Add (GameObject[] prefabs, int preloadAmount)
 Add an array of Prefabs or GameObjects to the Object Pool. More...
 
int[] Add (GameObject[] prefabs, int preloadAmount, bool spawnMore, bool slowMessage, bool handleParticles, bool trackSpawned, bool cullExtras, float cullInterval)
 Add an array of Prefabs or GameObjects to the Object Pool. More...
 
void Despawn (Transform transform)
 Despawn the specified Transform's GameObject back into it's Object Pool. More...
 
void Despawn (GameObject gameObject)
 Despawn the specified GameObject back into it's Object Pool. More...
 
void Despawn (Transform transform, int poolID)
 Despawn the specified Transform's GameObject back into it's Object Pool. More...
 
void Despawn (GameObject gameObject, int poolID)
 Despawn the specified GameObject back into it's Object Pool. More...
 
int GetPoolID (GameObject gameObject)
 Gets the Pool ID for the GameObject. More...
 
int GetPoolID (string prefabName)
 Gets the Pool ID by name. More...
 
bool Remove (GameObject gameObject, bool destroyImmediate)
 Remove the specified GameObject from it's Object Pool. More...
 
GameObject Spawn (Transform transform)
 Spawn a GameObject from it's Object Pool. More...
 
GameObject Spawn (GameObject gameObject)
 Spawn a GameObject from it's Object Pool. More...
 
GameObject Spawn (Transform transform, Vector3 position, Quaternion rotation)
 Spawn a GameObject from it's Object Pool. More...
 
GameObject Spawn (GameObject gameObject, Vector3 position, Quaternion rotation)
 Spawn a GameObject from it's Object Pool. More...
 
GameObject Spawn (int poolID)
 Spawn a GameObject from it's Object Pool. More...
 
GameObject Spawn (int poolID, Vector3 position, Quaternion rotation)
 Spawn a GameObject from it's Object Pool. More...
 

Detailed Description

A drop in implementation of the Hydrogen.Core.ObjectPool. This simply makes the class an accessible singleton with some very simple additional functionality.

Definition at line 36 of file hObjectPool.cs.

Member Function Documentation

override void hObjectPool.Awake ( )
protectedvirtual

Unity's Awake Event

Reimplemented from Hydrogen.Core.ObjectPool.

Definition at line 94 of file hObjectPool.cs.

95  {
96  // Make sure to do the object pools normal initialization
97  base.Awake ();
98 
99  // Should this gameObject be kept around :) I think so.
100  if (Persistent)
101  DontDestroyOnLoad (gameObject);
102 
103  }
bool Persistent
Should this object pool survive scene switches?
Definition: hObjectPool.cs:41
static bool hObjectPool.Exists ( )
static

Does an Object Pool already exist?

Definition at line 86 of file hObjectPool.cs.

87  {
88  return _staticInstance != null;
89  }

Member Data Documentation

bool hObjectPool.Persistent = true

Should this object pool survive scene switches?

Definition at line 41 of file hObjectPool.cs.

Property Documentation

hObjectPool hObjectPool.Instance
staticget

Gets the object pool instance, creating one if none is found.

The Object Pool.

Definition at line 63 of file hObjectPool.cs.