Update EditorTools.cs

pull/4/head
hevinci 2022-03-16 00:00:28 +08:00
parent 857eb1d0bb
commit 6bd48845d2
1 changed files with 33 additions and 1 deletions

View File

@ -7,7 +7,6 @@ using System.Text;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEditor;
using UnityEditor.Animations;
namespace YooAsset.Editor
{
@ -413,6 +412,8 @@ namespace YooAsset.Editor
#endregion
#region 路径
private static string YooAssetPath;
/// <summary>
/// 获取规范的路径
/// </summary>
@ -421,6 +422,37 @@ namespace YooAsset.Editor
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
}
/// <summary>
/// 获取资源框架目录路径
/// </summary>
public static string GetYooAssetPath()
{
if (string.IsNullOrEmpty(YooAssetPath) == false)
return YooAssetPath;
string packagesPath = ("Packages/com.tuyoo.yooasset/README.md");
var obj = AssetDatabase.LoadAssetAtPath(packagesPath, typeof(TextAsset));
if(obj != null)
{
YooAssetPath = "Packages/com.tuyoo.yooasset/";
return YooAssetPath;
}
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
Debug.LogError("Not found YooAsset Folder!");
return string.Empty;
}
if (allDirectorys.Length > 1)
{
Debug.LogError("Found multiple YooAsset Folders!");
return string.Empty;
}
YooAssetPath = AbsolutePathToAssetPath(allDirectorys[0]);
return YooAssetPath;
}
/// <summary>
/// 获取项目工程路径
/// </summary>