Description
The WaitForChildEffects
field is a boolean property of the TemporaryEffect
class. It determines whether the destruction of a GameObject
should be delayed until all child components that implement the ITemporaryEffect
interface have completed their effects. This is particularly useful for ensuring that any ongoing visual or audio effects are allowed to finish before the GameObject
is destroyed.
Usage
To use the WaitForChildEffects
field, simply set it to true
or false
depending on whether you want to wait for child effects to complete before destroying the GameObject
. This field is public and can be accessed directly from an instance of the TemporaryEffect
class.
Example
// Example of using the WaitForChildEffects field
// Create a new TemporaryEffect component
TemporaryEffect tempEffect = new TemporaryEffect();
// Set the duration after which the GameObject should be destroyed
tempEffect.DestroyAfterSeconds = 5.0f;
// Set to true to wait for child effects to complete before destruction
tempEffect.WaitForChildEffects = true;
// Add the TemporaryEffect component to a GameObject
GameObject myGameObject = new GameObject();
myGameObject.AddComponent(tempEffect);
// The GameObject will be destroyed after 5 seconds, but only after all child effects are complete if WaitForChildEffects is true.