using UnityEngine;
public static class GameObjectEx
{
public static void Destroy(this GameObject obj)
{
if (obj == null) return;
Object.Destroy(obj);
}
public static void SetLayerEx(this GameObject obj, int layer, int exceptLayer = -1)
{
if (obj == null) return;
if (obj.layer != exceptLayer)
obj.layer = layer;
var trans = obj.transform;
for (var i = 0; i < trans.childCount; ++i)
{
var child = trans.GetChild(i);
SetLayerEx(child.gameObject, layer, exceptLayer);
}
}
///
/// 修改缩放的方式显示隐藏
///
///
///
public static void IsScaleShow(this GameObject go, bool isShow)
{
if (go == null)
return;
if (isShow)
go.transform.localScale = Vector3.one;
else
go.transform.localScale = Vector3.zero;
}
}