FindMode EnabledInSelfAndDescendants

robot_2Generated
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 hierarchy of game objects. The EnabledInSelfAndDescendants mode specifically targets components that are enabled within the current game object and all of its descendant objects.

Usage

Use the EnabledInSelfAndDescendants field when you need to find all enabled components starting from a specific game object and including all of its descendants. This is particularly useful when you want to perform operations on all active components within a subtree of your game object hierarchy.

Example

// Example of using FindMode.EnabledInSelfAndDescendants

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

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