/// <summary> /// Gets a component in the hierarchy, by iterating through "hierarchy levels" instead of plain recusivity as /// GetComponentsInChildren() would do. /// </summary> /// <param name="_ComponentType">The type of the component you want to get.</param> /// <param name="_IncludeSelf">If enabled, try get component on the source object.</param> /// <param name="_IncludeInactive">If enabled, try get component on disabled objects.</param> /// <returns>Returns the first component of the given type found in the hierarchy.</returns> public static Component GetComponentInHierarchy(this Component _Obj, Type _ComponentType, bool _IncludeSelf = true, bool _IncludeInactive = false) { return(GameObjectExtension.GetComponentInHierarchy(_Obj.gameObject, _ComponentType, _IncludeSelf, _IncludeInactive)); }
/// <summary> /// Gets a component in the hierarchy, by iterating through "hierarchy levels" instead of plain recusivity as /// GetComponentsInChildren() would do. /// </summary> /// <typeparam name="T">The type of the component you want to get.</typeparam> /// <param name="_IncludeSelf">If enabled, try get component on the source object.</param> /// <param name="_IncludeInactive">If enabled, try get component on disabled objects.</param> /// <returns>Returns the first component of the given type found in the hierarchy.</returns> public static T GetComponentInHierarchy <T>(this Component _Obj, bool _IncludeSelf = true, bool _IncludeInactive = false) where T : Component { return(GameObjectExtension.GetComponentInHierarchy <T>(_Obj.gameObject, _IncludeSelf, _IncludeInactive)); }