Пример #1
0
 public static void ResetRenderQueueRecursively(GameObject root)
 {
     XUtility.ForeachComponentRecursively <Renderer>(root,
                                                     r =>
     {
         foreach (Material m in r.materials)
         {
             if (m == null)
             {
                 continue;
             }
             m.renderQueue = m.shader.renderQueue;
         }
     });
 }
Пример #2
0
 public static void ForeachComponentRecursively <T>(GameObject root, System.Action <T> func) where T : Component
 {
     if (root == null || func == null)
     {
         return;
     }
     T[] components = root.GetComponents <T>();
     foreach (var c in components)
     {
         func(c);
     }
     foreach (Transform t in root.transform)
     {
         XUtility.ForeachComponentRecursively(t.gameObject, func);
     }
 }
Пример #3
0
 public static void SetColliderEnabledRecursively(GameObject root, bool enabled)
 {
     XUtility.ForeachComponentRecursively <Collider>(root, c => c.enabled = enabled);
 }
Пример #4
0
        public static void SetLayerRecursively <T>(GameObject root, string layerName) where T : Component
        {
            int layer = LayerMask.NameToLayer(layerName);

            XUtility.ForeachComponentRecursively <T>(root, c => c.gameObject.layer = layer);
        }