ソースコード
using UnityEngine; public static class GameObjectExtensions { /// <summary> /// インターフェイスを指定して複数のコンポーネントを取得します /// </summary> public static T[] GetInterfacesOfComponent<T>( this GameObject self ) where T : class { var result = new List<T>(); foreach ( var n in self.GetComponents<Component>() ) { var component = n as T; if ( component != null ) { result.Add( component ); } } return result.ToArray(); } }