Update EditorTools.cs

修复Assets目录下存在多个YooAsset同名文件夹时,工具窗口无法显示的问题。
修复通过Packages导入YooAsset,工具窗口无法显示的问题。
pull/4/head
hevinci 2022-04-07 10:17:42 +08:00
parent 25088918d3
commit 0d7c93ac55
1 changed files with 37 additions and 23 deletions

View File

@ -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)
{
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;
}