using UnityEngine;
using UnityEditor;
using System.Collections;
public class NTEditorMenu : MonoBehaviour {
[MenuItem("Game/NTTool/坐标取整", false, 3)]
static void ResetPositionToInt()
{
GameObject obj = Selection.activeGameObject;
if (obj != null)
{
ResetPositonToIntByTransform(obj.transform);
}
Debug.Log("坐标设置完成");
}
static void ResetPositonToIntByTransform(Transform trans)
{
for (int i = 0; i < trans.childCount; i++)
{
Transform t = trans.GetChild(i).transform;
t.localPosition = new Vector3((int)t.transform.localPosition.x, (int)t.transform.localPosition.y, (int)t.transform.localPosition.z);
if (t.childCount > 0)
{
ResetPositonToIntByTransform(t);
}
}
}
}
Edtior
最新推荐文章于 2024-09-13 21:59:05 发布