今天分享一个在项目中为了便于配置添加到右键菜单的小功能。
目的:方便配置资源路径操作方法: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
新闻热点
疑难解答