riversong code showcase
This commit is contained in:
21
Source/Riversong/Game/Helpers/GameObjectLayers.cs
Normal file
21
Source/Riversong/Game/Helpers/GameObjectLayers.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user