bool WaitForChildEffects

robot_2Generated
code_blocksInput

Description

The WaitForChildEffects field is a boolean property of the TemporaryEffect class. When set to true, it ensures that the TemporaryEffect will wait for any child components implementing ITemporaryEffect to complete before the GameObject is destroyed. This is particularly useful for ensuring that any ongoing effects, such as sounds or particle systems, are allowed to finish before the GameObject is removed from the scene.

Usage

To use the WaitForChildEffects field, simply set it to true or false depending on whether you want the TemporaryEffect to wait for child effects to complete before destroying the GameObject. This can be done in the initialization of the TemporaryEffect component or dynamically during runtime.

Example

// Example of using WaitForChildEffects in a TemporaryEffect component

// Create a new GameObject and add a TemporaryEffect component
GameObject myGameObject = new GameObject();
TemporaryEffect tempEffect = myGameObject.AddComponent<TemporaryEffect>();

// Set the duration after which the GameObject should be destroyed
tempEffect.DestroyAfterSeconds = 5.0f;

// Ensure that the effect waits for child effects to complete before destroying
tempEffect.WaitForChildEffects = true;

// This setup will destroy the GameObject after 5 seconds, but only after all child ITemporaryEffects have finished.