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