using UnityEditor;
using UnityEngine;
public class ObjPathCopyTool : Editor
{
[MenuItem("GameObject/CopyPath %Q", false, 1)]
static void CopyPath()
{
Object[] objs = Selection.objects;
if (objs.Length < 1)
return;
GameObject obj = objs[0] as GameObject;
if (!obj)
return;
string path = obj.name;
Transform parent = obj.transform.parent;
while (parent)
{
path = string.Format("{0}/{1}", parent.name, path);
parent = parent.parent;
}
Debug.Log(path);
CopyString(path);
}
static void CopyString(string str)
{
TextEditor te = new TextEditor();
te.text = str;
te.SelectAll();
te.Copy();
}
}
UnityEditor-复制对象路径
最新推荐文章于 2024-05-07 12:18:32 发布