From 6bd48845d22a462763fbdfbb222b38cd08b5dbf8 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 16 Mar 2022 00:00:28 +0800 Subject: [PATCH] Update EditorTools.cs --- Assets/YooAsset/Editor/EditorTools.cs | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs index 3994922..f8d2b78 100644 --- a/Assets/YooAsset/Editor/EditorTools.cs +++ b/Assets/YooAsset/Editor/EditorTools.cs @@ -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; + /// /// 获取规范的路径 /// @@ -421,6 +422,37 @@ namespace YooAsset.Editor return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式 } + /// + /// 获取资源框架目录路径 + /// + 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; + } + /// /// 获取项目工程路径 ///