Skip to content

Commit 8b5a27f

Browse files
committed
add extension to set layers for whole hierarchy
1 parent 71c4e36 commit 8b5a27f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using UnityEngine;
7+
8+
namespace OpenTS2
9+
{
10+
public static class GameObjectExtensions
11+
{
12+
public static void SetLayerHierarchy(this GameObject go, int layer)
13+
{
14+
var transforms = go.GetComponentsInChildren<Transform>();
15+
foreach(var transform in transforms)
16+
{
17+
transform.gameObject.layer = layer;
18+
}
19+
}
20+
}
21+
}

Assets/Scripts/OpenTS2/GameObjectExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)