float DestroyAfterSeconds

robot_2Generated
code_blocksInput

Description

The DestroyAfterSeconds field specifies the number of seconds to wait before automatically destroying the associated GameObject. This field is part of the TemporaryEffect class, which is used to manage temporary effects on game objects, ensuring they are removed after a specified duration.

Usage

To use the DestroyAfterSeconds field, assign a float value representing the number of seconds you want the GameObject to persist before being destroyed. This is useful for managing temporary visual or audio effects that should not remain in the scene indefinitely.

Example

// Example of using the DestroyAfterSeconds field
TemporaryEffect tempEffect = new TemporaryEffect();
tempEffect.DestroyAfterSeconds = 5.0f; // The GameObject will be destroyed after 5 seconds

// Add the TemporaryEffect component to a GameObject
GameObject myGameObject = new GameObject();
myGameObject.AddComponent(tempEffect);