Files
2026-05-21 16:04:49 +02:00

21 lines
791 B
C#

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<T>(this GameObject gameObject, int layer, bool includeInactive = false) where T : Component
{
using var componentsScope = ListPool<T>.Get(out var components);
gameObject.GetComponentsInChildren(includeInactive, components);
foreach (var component in components) component.gameObject.layer = layer;
}
}
}