Update EditorTools.cs
修复Assets目录下存在多个YooAsset同名文件夹时,工具窗口无法显示的问题。 修复通过Packages导入YooAsset,工具窗口无法显示的问题。pull/4/head
parent
25088918d3
commit
0d7c93ac55
|
@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class EditorTools
|
public static class EditorTools
|
||||||
{
|
{
|
||||||
#region Assembly
|
#region Assembly
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 调用私有的静态方法
|
/// 调用私有的静态方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -49,9 +49,9 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return methodInfo.Invoke(null, parameters);
|
return methodInfo.Invoke(null, parameters);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EditorUtility
|
#region EditorUtility
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 搜集资源
|
/// 搜集资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -156,9 +156,9 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
EditorUtility.ClearProgressBar();
|
EditorUtility.ClearProgressBar();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EditorWindow
|
#region EditorWindow
|
||||||
public static void FocusUnitySceneWindow()
|
public static void FocusUnitySceneWindow()
|
||||||
{
|
{
|
||||||
EditorWindow.FocusWindowIfItsOpen<SceneView>();
|
EditorWindow.FocusWindowIfItsOpen<SceneView>();
|
||||||
|
@ -188,9 +188,9 @@ namespace YooAsset.Editor
|
||||||
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.ConsoleWindow");
|
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.ConsoleWindow");
|
||||||
EditorWindow.GetWindow(T, false, "Console", true);
|
EditorWindow.GetWindow(T, false, "Console", true);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 控制台
|
#region 控制台
|
||||||
private static MethodInfo _clearConsoleMethod;
|
private static MethodInfo _clearConsoleMethod;
|
||||||
private static MethodInfo ClearConsoleMethod
|
private static MethodInfo ClearConsoleMethod
|
||||||
{
|
{
|
||||||
|
@ -213,9 +213,9 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
ClearConsoleMethod.Invoke(new object(), null);
|
ClearConsoleMethod.Invoke(new object(), null);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 文件
|
#region 文件
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建文件所在的目录
|
/// 创建文件所在的目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -409,9 +409,9 @@ namespace YooAsset.Editor
|
||||||
else
|
else
|
||||||
return Encoding.UTF8.GetString(bytes.ToArray());
|
return Encoding.UTF8.GetString(bytes.ToArray());
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 路径
|
#region 路径
|
||||||
private static string YooAssetPath;
|
private static string YooAssetPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -430,26 +430,40 @@ namespace YooAsset.Editor
|
||||||
if (string.IsNullOrEmpty(YooAssetPath) == false)
|
if (string.IsNullOrEmpty(YooAssetPath) == false)
|
||||||
return YooAssetPath;
|
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));
|
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;
|
return YooAssetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 从Assets目录下搜索
|
||||||
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
|
string[] allDirectorys = Directory.GetDirectories(Application.dataPath, "YooAsset", SearchOption.AllDirectories);
|
||||||
if (allDirectorys.Length == 0)
|
if (allDirectorys.Length == 0)
|
||||||
{
|
{
|
||||||
Debug.LogError("Not found YooAsset Folder!");
|
Debug.LogError("Not found YooAsset Package !");
|
||||||
return string.Empty;
|
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;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
YooAssetPath = AbsolutePathToAssetPath(allDirectorys[0]);
|
|
||||||
|
YooAssetPath = AbsolutePathToAssetPath(targetDirectory);
|
||||||
return YooAssetPath;
|
return YooAssetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -504,9 +518,9 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 字符串
|
#region 字符串
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否含有中文
|
/// 是否含有中文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -567,9 +581,9 @@ namespace YooAsset.Editor
|
||||||
else
|
else
|
||||||
return content.Substring(startIndex + key.Length);
|
return content.Substring(startIndex + key.Length);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 玩家偏好
|
#region 玩家偏好
|
||||||
// 枚举
|
// 枚举
|
||||||
public static void PlayerSetEnum<T>(string key, T value)
|
public static void PlayerSetEnum<T>(string key, T value)
|
||||||
{
|
{
|
||||||
|
@ -581,6 +595,6 @@ namespace YooAsset.Editor
|
||||||
string enumName = EditorPrefs.GetString(key, defaultValue.ToString());
|
string enumName = EditorPrefs.GetString(key, defaultValue.ToString());
|
||||||
return StringUtility.NameToEnum<T>(enumName);
|
return StringUtility.NameToEnum<T>(enumName);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue