FindMode EnabledInSelfAndChildren

book_4_sparkGenerated
code_blocksInput

Description

The EnabledInSelfAndChildren field is a member of the FindMode enumeration in the Sandbox namespace. This enumeration is used to specify the mode of searching for components within a game object hierarchy. The EnabledInSelfAndChildren mode specifically targets components that are enabled within the current game object and its immediate children.

Usage

Use the EnabledInSelfAndChildren field when you need to find all components that are enabled in the current game object and its direct children. This is particularly useful when you want to perform operations only on active components within a specific scope of the hierarchy.

Example

// Example of using FindMode.EnabledInSelfAndChildren

// Assume 'gameObject' is a reference to a GameObject
var components = gameObject.FindComponents<SomeComponent>(FindMode.EnabledInSelfAndChildren);

// Iterate over the found components
foreach (var component in components)
{
    // Perform operations on each enabled component
    component.DoSomething();
}