mirror of
https://github.com/Raicuparta/nomai-vr.git
synced 2025-12-11 20:15:08 +01:00
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace NomaiVR.Helpers
|
|
{
|
|
public static class LayerHelper
|
|
{
|
|
public static List<GameObject> GetObjectsInLayer(string layerName)
|
|
{
|
|
var layer = LayerMask.NameToLayer(layerName);
|
|
var ret = new List<GameObject>();
|
|
var all = Object.FindObjectsOfType<GameObject>();
|
|
|
|
foreach (var t in all)
|
|
{
|
|
if (t.layer == layer)
|
|
{
|
|
ret.Add(t.gameObject);
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
public static void ChangeLayerRecursive(GameObject obj, string maskName)
|
|
{
|
|
ChangeLayerRecursive(obj, LayerMask.NameToLayer(maskName));
|
|
}
|
|
|
|
public static void ChangeLayerRecursive(GameObject obj, LayerMask mask)
|
|
{
|
|
obj.layer = mask;
|
|
foreach (Transform child in obj.transform)
|
|
{
|
|
ChangeLayerRecursive(child.gameObject, mask);
|
|
}
|
|
}
|
|
}
|
|
}
|