Description
The Active
property of a Component
in the Sandbox API indicates whether the component is currently active in the scene. A component is considered active if it is enabled and all of its ancestor GameObject
s are also enabled. This property is useful for determining if a component is operational within the scene context.
Usage
Use the Active
property to check if a component is active in the scene. This is particularly useful when you need to ensure that a component is not only enabled but also that its parent GameObject
and all ancestors are enabled, ensuring the component is fully operational.
Example
// Example of checking if a component is active
Component myComponent = someGameObject.GetComponent<MyComponent>();
if (myComponent.Active)
{
// Perform actions knowing the component is active
myComponent.DoSomething();
}