FindMode EnabledInSelfAndDescendants

book_4_sparkGenerated
code_blocksInput

Description

The EnabledInSelfAndDescendants 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 EnabledInSelfAndDescendants mode allows you to find components that are enabled within the current game object and all of its descendant objects.

Usage

Use the EnabledInSelfAndDescendants field when you need to search for components that are enabled in both the current game object and its descendants. This is particularly useful when you want to perform operations on all active components within a specific hierarchy.

Example

// Example of using FindMode.EnabledInSelfAndDescendants

// Assume 'gameObject' is an instance of GameObject
var components = gameObject.FindComponents<SomeComponent>(FindMode.EnabledInSelfAndDescendants);

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