using UnityEditor;
using UnityEngine;
public class CopyPath : Editor
{
private static readonly TextEditor CopyTool = new TextEditor();
[MenuItem("Tools/CopyPath #R", false)]
static void CopyPathPath()
{
Transform trans = Selection.activeTransform;
if (null == trans) return;
CopyTool.text = GetPath(trans);
CopyTool.SelectAll();
CopyTool.Copy();
Debug.Log(GetPath(trans));
}
public static string GetPath(Transform trans)
{
if (null == trans) return string.Empty;
if (null == trans.parent) return trans.name;
return GetPath(trans.parent) + "/" + trans.name;
}
}
|