Unity 提取编辑器Assets下文件夹或文件绝对路径

Unity 提取编辑器Assets下文件夹或文件绝对路径_第1张图片
Unity 提取编辑器Assets下文件夹或文件绝对路径_第2张图片
复制的路径会保存到操作系统的剪贴板中,使用Ctrl + V 即可粘贴。

using UnityEditor;
using UnityEngine;

namespace ZYF
{
    public class ProjectCopyPath : MonoBehaviour {
        [MenuItem("Assets/复制绝对路径", priority = 19)]
        static void CopyTransPath()
        {
            string path = "";
            if (Selection.assetGUIDs != null && Selection.assetGUIDs.Length == 1)
            {
                path = AssetDatabase.GUIDToAssetPath(Selection.assetGUIDs[0]);
            }
            //去除开头
            string pAssets = Application.streamingAssetsPath.Replace("StreamingAssets", "");
            pAssets = pAssets.Replace("/Assets","");
            string fPath = pAssets + path;
            GUIUtility.systemCopyBuffer = fPath;
            Debug.Log("已复制绝对路径:"+fPath);
        }
	
    } 

}

你可能感兴趣的:(Unity,unity,路径)