21 lines
791 B
C#
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;
|
|
}
|
|
}
|
|
} |