Description
The FindMode.InAncestors
field is a member of the FindMode
enumeration in the Sandbox namespace. It specifies a search mode for finding components within all ancestor objects of a given GameObject. This includes the parent, the parent's parent, and so on, up the hierarchy.
Usage
Use FindMode.InAncestors
when you need to locate components that are not directly attached to the current GameObject but are present in any of its ancestor objects. This can be useful for accessing shared components or settings that are defined higher up in the hierarchy.
Example
// Example of using FindMode.InAncestors
GameObject myObject = ...; // Assume this is your current GameObject
var component = myObject.FindComponent<MyComponent>(FindMode.InAncestors);
if (component != null)
{
// Do something with the component
}