예제 #1
0
 public static void AddComponentRecursive <T>(this GameObject gameObject, ComponentTestDelegate testDelegate) where T : Component
 {
     gameObject.AddComponent <T>(testDelegate);
     foreach (Transform child in gameObject.transform)
     {
         child.gameObject.AddComponentRecursive <T>(testDelegate);
     }
 }
예제 #2
0
 public static T AddComponent <T>(this GameObject gameObject, ComponentTestDelegate testDelegate) where T : Component
 {
     if (testDelegate(gameObject))
     {
         return(gameObject.AddComponent <T>());
     }
     return(null);
 }