using UnityEditor;using UnityEngine;public class ObjPathCopyTool : ScriptableObject{ [MenuItem("Custom/Copy path %Q")] //自定义快捷键 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(); }}
Unity自定义快捷:
% - CTRL on Windows / CMD on OSX
‘# - Shift’& -AltLEFT/RIGHT/UP/DOWN - Arrow keysF1 … F2 - F keysHOME,END,PGUP,PGDN字母键 - _ + 字母(如:_g代表按键)还可以几种合并