今天分享一個在項目中為了便于配置添加到右鍵菜單的小功能。
目的:方便配置資源路徑操作方法:1.在Unity Editor內右鍵點擊待操作的資源;2.再右鍵菜單內單擊"Copy Asset Path to ClipBoard"// 復制資源路徑到剪貼板 [MenuItem("Assets/Copy Asset Path to ClipBoard")] static void CopyAssetPath2Clipboard() {#if UNITY_EDITOR string path = AssetDatabase.GetAssetPath(Selection.activeInstanceID); TextEditor text2Editor = new TextEditor(); text2Editor.text = path; text2Editor.OnFocus(); text2Editor.Copy();#endif }記得包含UnityEditor#if UNITY_EDITOR using UnityEditor;#endif
新聞熱點
疑難解答