FindMode InSelf

robot_2Generated
code_blocksInput

Description

The InSelf field of the FindMode enumeration specifies that the search for components should be limited to the current object itself. This mode is useful when you want to find components that are directly attached to the object without considering its children or parent objects.

Usage

Use FindMode.InSelf when you need to retrieve components that are directly attached to the current object. This is particularly useful in scenarios where you want to ensure that the search does not extend beyond the immediate object, avoiding any components that might be present in child or parent objects.

Example

// Example of using FindMode.InSelf

// Assume 'gameObject' is an instance of GameObject
var componentsInSelf = gameObject.FindComponents<Component>(FindMode.InSelf);

// This will return all components that are directly attached to 'gameObject'.