bool Enabled { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The Enabled property of a Component in the Sandbox API indicates the desired enable state of the component. This property does not necessarily reflect whether the component is currently active in the scene, as its parent GameObject might be disabled. To determine if the component is truly active, you should check the Active property.

Usage

Use the Enabled property to set or get the desired enable state of a component. This is useful for controlling whether a component should be active or inactive, but remember that the actual active state also depends on the parent GameObject's state.

Example

// Example of using the Enabled property
Component myComponent = myGameObject.GetComponent<MyComponent>();

// Enable the component
myComponent.Enabled = true;

// Check if the component is enabled
bool isEnabled = myComponent.Enabled;

// Note: To check if the component is truly active, use the Active property
bool isActive = myComponent.Active;