using UnityEngine; public static class LayerUtils { public static void SetAllChildsLayer(GameObject go, int layer, bool includeInactive = false) { var list = go.GetComponentsInChildren(includeInactive); for (int i = 0; i < list.Length; i++) { list[i].gameObject.layer = layer; } } /// /// 只修改Default层级 /// /// /// /// public static void SetAllChildDefLayer(GameObject go, int layer, bool includeInactive = false) { var list = go.GetComponentsInChildren(includeInactive); for (int i = 0; i < list.Length; i++) { if (list[i].gameObject.layer == 0) list[i].gameObject.layer = layer; } } }