示例: 使用方法:将脚本放入Editor文件夹下,然后选中需要复制Position的物体,选择编辑器顶部的[复制坐标],需要粘贴的地方Ctrl+V即可
using UnityEditor;
using UnityEngine;
public class CopyObjTransformData : Editor
{
[UnityEditor.MenuItem("复制节点Transform信息/复制坐标")]
static void CopyXYZ()
{
GameObject obj = UnityEditor.Selection.activeGameObject;
if (obj != null)
{
string ret = obj.transform.localPosition.x + "f,"
+ obj.transform.localPosition.y + "f,"
+ obj.transform.localPosition.z + "f";
GUIUtility.systemCopyBuffer = ret;
}
}
[UnityEditor.MenuItem("复制节点Transform信息/复制旋转")]
static void CopyObjRotation()
{
GameObject obj = UnityEditor.Selection.activeGameObject;
if (obj != null)
{
string ret = obj.transform.localEulerAngles.x + "f," + obj.transform.localEulerAngles.y + "f," +
obj.transform.localEulerAngles.z + "f";
GUIUtility.systemCopyBuffer = ret;
}
}
}
|