diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs
index 9e9eb6c..0f77e0a 100644
--- a/Assets/YooAsset/Editor/EditorTools.cs
+++ b/Assets/YooAsset/Editor/EditorTools.cs
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
///
public static class EditorTools
{
-#region Assembly
+ #region Assembly
///
/// 调用私有的静态方法
///
@@ -49,9 +49,9 @@ namespace YooAsset.Editor
}
return methodInfo.Invoke(null, parameters);
}
-#endregion
+ #endregion
-#region EditorUtility
+ #region EditorUtility
///
/// 搜集资源
///
@@ -156,9 +156,9 @@ namespace YooAsset.Editor
{
EditorUtility.ClearProgressBar();
}
-#endregion
+ #endregion
-#region EditorWindow
+ #region EditorWindow
public static void FocusUnitySceneWindow()
{
EditorWindow.FocusWindowIfItsOpen();
@@ -188,9 +188,9 @@ namespace YooAsset.Editor
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.ConsoleWindow");
EditorWindow.GetWindow(T, false, "Console", true);
}
-#endregion
+ #endregion
-#region 控制台
+ #region 控制台
private static MethodInfo _clearConsoleMethod;
private static MethodInfo ClearConsoleMethod
{
@@ -213,9 +213,9 @@ namespace YooAsset.Editor
{
ClearConsoleMethod.Invoke(new object(), null);
}
-#endregion
+ #endregion
-#region 文件
+ #region 文件
///
/// 创建文件所在的目录
///
@@ -409,9 +409,9 @@ namespace YooAsset.Editor
else
return Encoding.UTF8.GetString(bytes.ToArray());
}
-#endregion
+ #endregion
-#region 路径
+ #region 路径
private static string YooAssetPath;
///
@@ -430,26 +430,40 @@ namespace YooAsset.Editor
if (string.IsNullOrEmpty(YooAssetPath) == false)
return YooAssetPath;
- string packagesPath = ("Packages/com.tuyoo.yooasset/README.md");
+ // 从Pakcages目录下搜索
+ string packagesPath = ("Packages/com.tuyoogame.yooasset/README.md");
var obj = AssetDatabase.LoadAssetAtPath(packagesPath, typeof(TextAsset));
- if(obj != null)
+ if (obj != null)
{
- YooAssetPath = "Packages/com.tuyoo.yooasset/";
+ YooAssetPath = "Packages/com.tuyoogame.yooasset/";
return YooAssetPath;
}
+ // 从Assets目录下搜索
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
if (allDirectorys.Length == 0)
{
- Debug.LogError("Not found YooAsset Folder!");
+ Debug.LogError("Not found YooAsset Package !");
return string.Empty;
}
- if (allDirectorys.Length > 1)
+
+ string targetDirectory = string.Empty;
+ foreach (var directory in allDirectorys)
{
- Debug.LogError("Found multiple YooAsset Folders!");
+ string asmdefFilePath = $"{directory}/Editor/YooAsset.Editor.asmdef";
+ if (File.Exists(asmdefFilePath))
+ {
+ targetDirectory = directory;
+ break;
+ }
+ }
+ if (string.IsNullOrEmpty(targetDirectory))
+ {
+ Debug.LogError("Should never get here !");
return string.Empty;
}
- YooAssetPath = AbsolutePathToAssetPath(allDirectorys[0]);
+
+ YooAssetPath = AbsolutePathToAssetPath(targetDirectory);
return YooAssetPath;
}
@@ -504,9 +518,9 @@ namespace YooAsset.Editor
}
return string.Empty;
}
-#endregion
+ #endregion
-#region 字符串
+ #region 字符串
///
/// 是否含有中文
///
@@ -567,9 +581,9 @@ namespace YooAsset.Editor
else
return content.Substring(startIndex + key.Length);
}
-#endregion
+ #endregion
-#region 玩家偏好
+ #region 玩家偏好
// 枚举
public static void PlayerSetEnum(string key, T value)
{
@@ -581,6 +595,6 @@ namespace YooAsset.Editor
string enumName = EditorPrefs.GetString(key, defaultValue.ToString());
return StringUtility.NameToEnum(enumName);
}
-#endregion
+ #endregion
}
}
\ No newline at end of file