您的位置:首页 > 移动开发 > Unity3D

Unity资源快速查找小工具

2017-05-24 10:45 295 查看
相信你们经常会有在
Resources.Load("xxx");
的时候填写出来错误的路径,而且每次填写路径太麻烦,因此下了一下的小工具,由于本人正则不太好,写的麻烦了一些,代码如下:

[MenuItem("Assets/Path")]
public static void GetPath()
{
Object[] selections = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
if (selections.Length == 0)
return;
string assetPath = AssetDatabase.GetAssetPath(selections[0]);
assetPath = Regex.Replace(assetPath, "Assets/", "");
assetPath = Regex.Replace(assetPath, @"(\.[\D]+)$", "");
assetPath = Regex.Replace(assetPath, "Resources/", "");
Debug.Log(assetPath);
GUIUtility.systemCopyBuffer = assetPath;
}


直接在project下面右键就会出现path,点击path后会自动复制到粘贴板内和打印出Log,可以直接复制到代码中,在Resources下目录的文件会自动删除Resources。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: