您当前的位置: 首页 >  unity
  • 3浏览

    0关注

    157博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

牙膏上的小苏打2333 发布时间:2022-03-02 12:55:58 ,浏览量:3

在这里插入图片描述 在这里插入图片描述 复制的路径会保存到操作系统的剪贴板中,使用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);
        }
	
    } 

}
关注
打赏
1664520285
查看更多评论
立即登录/注册

微信扫码登录

0.3928s