using UnityEngine; using UnityEngine.Pool; namespace DanieleMarotta.RiversongCodeShowcase { public static class GameObjectLayers { public static readonly int Default = LayerMask.NameToLayer("Default"); public static readonly int Terrain = LayerMask.NameToLayer("Terrain"); public static readonly int IgnoreAoE = LayerMask.NameToLayer("Ignore AoE"); public static void SetLayerRecursively(this GameObject gameObject, int layer, bool includeInactive = false) where T : Component { using var componentsScope = ListPool.Get(out var components); gameObject.GetComponentsInChildren(includeInactive, components); foreach (var component in components) component.gameObject.layer = layer; } } }