Hydrogen Framework
1.3.1
|
An internal pooling system used within the Hydrogen Framework. More...
Public Member Functions | |
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... | |
Public Attributes | |
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 | |
virtual void | Awake () |
Unity's Awake Event More... | |
virtual void | Update () |
Unity's Update Event More... | |
An internal pooling system used within the Hydrogen Framework.
Each GameObject / Prefab has its own pool, this is done for many reasons, but ultimately seems to be the best performance scenario.
Definition at line 41 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.Add | ( | GameObject | prefab | ) |
Add a Prefab or GameObject to the Object Pool.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefab | The Prefab or GameObject. |
Definition at line 117 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.Add | ( | GameObject | prefab, |
int | preloadAmount | ||
) |
Add a Prefab or GameObject to the Object Pool.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefab | The Prefab or GameObject. |
preloadAmount | The number of objects that should be preloaded. |
Definition at line 136 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.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.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefab | The Prefab or GameObject. |
preloadAmount | The number of objects that should be preloaded. |
spawnMore | Should more objects be added to the pool as needed? |
slowMessage | Should Unity's SendMessage be used? |
handleParticles | Should accomodations for Particles be made? |
trackSpawned | Should spawned objects be tracked? |
cullExtras | Should extra objects be removed from the Object Pool when not in use? |
cullInterval | How often should we check for extras to cull. |
Definition at line 161 of file ObjectPool.cs.
int [] Hydrogen.Core.ObjectPool.Add | ( | GameObject[] | prefabs | ) |
Add an array of Prefabs or GameObjects to the Object Pool.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefabs | An array of Prefabs or GameObjects. |
Definition at line 194 of file ObjectPool.cs.
int [] Hydrogen.Core.ObjectPool.Add | ( | GameObject[] | prefabs, |
int | preloadAmount | ||
) |
Add an array of Prefabs or GameObjects to the Object Pool.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefabs | An array of Prefabs or GameObjects. |
preloadAmount | The number of objects that should be preloaded. |
Definition at line 213 of file ObjectPool.cs.
int [] Hydrogen.Core.ObjectPool.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.
If you pass an existing GameObject from the scene, it will need to exist in the future to be able to spawn any additional objects outside of what was preloaded upon its addition to the Object Pool. It can be disabled, or inactive, it simply needs to exist if you want to add more later.
prefabs | An array of Prefabs or GameObjects. |
preloadAmount | The number of objects that should be preloaded. |
spawnMore | Should more objects be added to the pool as needed? |
slowMessage | Should Unity's SendMessage be used? |
handleParticles | Should accomodations for Particles be made? |
trackSpawned | Should spawned objects be tracked? |
cullExtras | Should extra objects be removed from the Object Pool when not in use? |
cullInterval | How often should we check for extras to cull. |
Definition at line 238 of file ObjectPool.cs.
|
protectedvirtual |
Unity's Awake Event
Reimplemented in hObjectPool.
Definition at line 415 of file ObjectPool.cs.
void Hydrogen.Core.ObjectPool.Despawn | ( | Transform | transform | ) |
Despawn the specified Transform's GameObject back into it's Object Pool.
This method should only be used if the Pool ID is not known.
transform | Target Transform |
Definition at line 258 of file ObjectPool.cs.
void Hydrogen.Core.ObjectPool.Despawn | ( | GameObject | gameObject | ) |
Despawn the specified GameObject back into it's Object Pool.
This method should only be used if the Pool ID is not known.
gameObject | Target GameObject. |
Definition at line 270 of file ObjectPool.cs.
void Hydrogen.Core.ObjectPool.Despawn | ( | Transform | transform, |
int | poolID | ||
) |
Despawn the specified Transform's GameObject back into it's Object Pool.
transform | Target Transform. |
poolID | The Pool ID |
Definition at line 280 of file ObjectPool.cs.
void Hydrogen.Core.ObjectPool.Despawn | ( | GameObject | gameObject, |
int | poolID | ||
) |
Despawn the specified GameObject back into it's Object Pool.
gameObject | Target GameObject |
poolID | The Pool ID |
Definition at line 290 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.GetPoolID | ( | GameObject | gameObject | ) |
Gets the Pool ID for the GameObject.
gameObject | Target GameObject. |
Definition at line 300 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.GetPoolID | ( | string | prefabName | ) |
Gets the Pool ID by name.
prefabName | Lookup Name |
Definition at line 310 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.Remove | ( | GameObject | gameObject, |
bool | destroyImmediate | ||
) |
Remove the specified GameObject from it's Object Pool.
gameObject | Target GameObject |
destroyImmediate | Should the object be destroied immediately. |
Definition at line 327 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | Transform | transform | ) |
Spawn a GameObject from it's Object Pool.
This method is slower then using Spawn(PoolID), as it is doing a lookup.
transform | Target Transform. |
Definition at line 347 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | GameObject | gameObject | ) |
Spawn a GameObject from it's Object Pool.
This method is slower then using Spawn(PoolID), as it is doing a lookup.
gameObject | Target GameObject. |
Definition at line 359 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | Transform | transform, |
Vector3 | position, | ||
Quaternion | rotation | ||
) |
Spawn a GameObject from it's Object Pool.
This method is slower then using Spawn(PoolID), as it is doing a lookup.
transform | Target Transform. |
position | Position at which to spawn GameObject. |
rotation | The rotation to set for the spawned GameObject. |
Definition at line 373 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | GameObject | gameObject, |
Vector3 | position, | ||
Quaternion | rotation | ||
) |
Spawn a GameObject from it's Object Pool.
This method is slower then using Spawn(PoolID), as it is doing a lookup.
gameObject | Target GameObject. |
position | Position at which to spawn GameObject. |
rotation | The rotation to set for the spawned GameObject. |
Definition at line 387 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | int | poolID | ) |
Spawn a GameObject from it's Object Pool.
poolID | Pool ID of Pool to spawn from. |
Definition at line 396 of file ObjectPool.cs.
GameObject Hydrogen.Core.ObjectPool.Spawn | ( | int | poolID, |
Vector3 | position, | ||
Quaternion | rotation | ||
) |
Spawn a GameObject from it's Object Pool.
poolID | Pool ID of Pool to spawn from. |
position | Position at which to spawn GameObject. |
rotation | The rotation to set for the spawned GameObject |
Definition at line 407 of file ObjectPool.cs.
|
protectedvirtual |
Unity's Update Event
Definition at line 438 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.CullExtras |
Should extra objects be culled when not in use?
The default value used when adding objects to the Object Pool.
Definition at line 49 of file ObjectPool.cs.
float Hydrogen.Core.ObjectPool.CullInterval = 3f |
How often should we look at culling extra objects.
The default value used when adding objects to the Object Pool.
Definition at line 56 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.HandleParticles = true |
Should particle systems be appropriately handled when despawning?
The default value used when adding objects to the Object Pool.
Definition at line 63 of file ObjectPool.cs.
ObjectPoolCollection [] Hydrogen.Core.ObjectPool.ObjectPools |
Our pooled object collections.
One for each GameObject / Prefab added to the Object Pool.
Definition at line 70 of file ObjectPool.cs.
int Hydrogen.Core.ObjectPool.PreloadAmount = 5 |
The number of objects to preload in an Object Pool.
The default value used when adding objects to the Object Pool.
Definition at line 77 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.SlowMessage |
Should Unity's SendMessage be used. (OnSpawned, WaitToDespawn, OnDespawned)
The default value used when adding objects to the Object Pool.
Definition at line 84 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.SpawnMore = true |
Should additional objects be spawned as needed?
The default value used when adding objects to the Object Pool.
Definition at line 91 of file ObjectPool.cs.
bool Hydrogen.Core.ObjectPool.TrackObjects |
Should objects be tracked when they are spawned?
Useful for when you need to keep track of what objects are in use. The default value used when adding objects to the Object Pool.
Definition at line 99 of file ObjectPool.cs.