An IPoolHandler that is passed a prefab directly.
More...
An IPoolHandler that is passed a prefab directly.
◆ DefaultPoolHandler()
Infohazard.Core.DefaultPoolHandler.DefaultPoolHandler |
( |
Spawnable |
prefab, |
|
|
Transform |
transform |
|
) |
| |
Construct DefaultPoolHandler for a given prefab, attached to a given Transform.
- Parameters
-
prefab | Prefab that this handler will spawn. |
transform | Transform to attach inactive instances to. |
◆ CheckClear()
void Infohazard.Core.DefaultPoolHandler.CheckClear |
( |
| ) |
|
|
protected |
◆ Clear()
virtual void Infohazard.Core.DefaultPoolHandler.Clear |
( |
| ) |
|
|
protectedvirtual |
Clear all the inactive instances from the pool to free up memory.
◆ Despawn()
virtual void Infohazard.Core.DefaultPoolHandler.Despawn |
( |
Spawnable |
instance | ) |
|
|
virtual |
Despawn an object, deactivating it and releasing it back to the pool.
- Parameters
-
instance | The object to be despawned. |
◆ Destroy()
virtual void Infohazard.Core.DefaultPoolHandler.Destroy |
( |
Spawnable |
obj | ) |
|
|
protectedvirtual |
Destroy an object after it is removed from the pool. Override to perform custom destruction logic.
This method is only used when an object is no longer needed and is permanently destroyed. To implement logic that happens every time an object is despawned, see OnRelease.
- Parameters
-
obj | The object to be destroyed. |
◆ Instantiate()
virtual Spawnable Infohazard.Core.DefaultPoolHandler.Instantiate |
( |
| ) |
|
|
protectedvirtual |
Instantiate an object to add to the pool. Override to perform custom instantiation logic.
This method is only used when a new object is needed and the pool is empty. To implement logic that happens every time an object is spawned, see OnGet. This method makes the spawned object inactive. If you implement your own instantiate logic instead of calling the base method, you should also make the object inactive.
- Returns
- The spawned object.
◆ OnGet()
virtual void Infohazard.Core.DefaultPoolHandler.OnGet |
( |
Spawnable |
obj | ) |
|
|
protectedvirtual |
Override to perform custom logic when an object is being spawned from the pool.
Invoked before the object is made active. This method is called every time a pooled object becomes active (including right after it is instantiated). To implement custom creation logic that only happens once per object, see Instantiate.
- Parameters
-
obj | The object being spawned. |
◆ OnRelease()
virtual void Infohazard.Core.DefaultPoolHandler.OnRelease |
( |
Spawnable |
obj | ) |
|
|
protectedvirtual |
Override to perform custom logic when an object is being despawned and released back to the pool.
Invoked before the object is made inactive. This method is called every time a pooled object becomes inactive (included right before it is destroyed). To implement cleanup creation logic that only happens once per object, see Destroy(Spawnable).
- Parameters
-
obj | The object being spawned. |
◆ Release()
virtual void Infohazard.Core.DefaultPoolHandler.Release |
( |
| ) |
|
|
virtual |
Remove a user from the pool, clearing inactive instances if user count reaches zero.
When removing the last user, all inactive instances will be destroyed, and any additional calls to Spawn will need to create a new object via Instantiate.
◆ Retain()
virtual void Infohazard.Core.DefaultPoolHandler.Retain |
( |
| ) |
|
|
virtual |
Add an additional user to the pool, ensuring pooled instances will remain available.
◆ ShouldClear()
virtual bool Infohazard.Core.DefaultPoolHandler.ShouldClear |
( |
| ) |
|
|
protectedvirtual |
Should the pool be cleared?
The base implementation returns true if RetainCount == 0.
- Returns
- True if the pool should be cleared.
◆ Spawn()
virtual Spawnable Infohazard.Core.DefaultPoolHandler.Spawn |
( |
| ) |
|
|
virtual |
Spawn an object from the pool, using an inactive instance from the pool if possible (otherwise, a new instance is created via Instantiate).
- Returns
- The spawned object.
◆ ToString()
override string Infohazard.Core.DefaultPoolHandler.ToString |
( |
| ) |
|
◆ Pool
The pool that will spawn the prefab.
◆ Prefab
Spawnable Infohazard.Core.DefaultPoolHandler.Prefab |
|
getprotected set |
The loaded prefab to be spawned by the handler.
◆ RetainCount
int Infohazard.Core.DefaultPoolHandler.RetainCount |
|
getprivate set |
◆ ShouldPool
virtual bool Infohazard.Core.DefaultPoolHandler.ShouldPool |
|
get |
◆ Transform
Transform Infohazard.Core.DefaultPoolHandler.Transform |
|
get |
The transform that inactive instances in the pool are parented to.
The documentation for this class was generated from the following file:
- Runtime/Pooling/DefaultPoolHandler.cs