ソースコード
using UnityEngine;
public static class GameObjectExtensions
{
<summary>
</summary>
public static T GetInterfaceOfComponentInChildren<T>(
this GameObject self,
bool includeInactive
) where T : class
{
foreach ( var n in self.GetComponentsInChildren<Component>( includeInactive ) )
{
var component = n as T;
if( component != null )
{
return component;
}
}
return null;
}
<summary>
</summary>
public static T GetInterfaceOfComponentInChildren<T>( this GameObject self ) where T : class
{
return self.GetInterfaceOfComponentInChildren<T>( false );
}
}
関連記事