Files
RedHotRoast-ios/Assets/Scripts/Extend/Unity/GameObjectExtend.cs
T

24 lines
739 B
C#

using UnityEngine;
namespace RedHotRoast
{
public static class GameObjectExtend
{
public static void SetParent(this GameObject gameObject, GameObject parentGo, bool worldPositionStays = false)
{
if (parentGo)
{
gameObject.transform.SetParent(parentGo.transform, worldPositionStays);
}
}
public static void SetLayer(this GameObject gameObject, string layerName)
{
Transform[] transArr = gameObject.transform.GetComponentsInChildren<Transform>();
for (int i = 0; i < transArr.Length; i++)
{
transArr[i].gameObject.layer = LayerMask.NameToLayer(layerName);
}
}
}
}