com.alicizax.unity.animatio.../Editor/Misc/EditorResourceTool.cs

45 lines
1.9 KiB
C#
Raw Normal View History

2025-02-07 16:05:13 +08:00
using System.Collections.Generic;
using UnityEngine;
namespace AlicizaX.AnimationFlow.Editor {
public static class EditorResourceTool {
public static string editorAssets;
public static bool LocateEditorAssets() {
string projectPath = Application.dataPath;
if (projectPath.EndsWith("/Assets")) {
projectPath = projectPath.Remove(projectPath.Length - ("Assets".Length));
}
editorAssets = "Packages/com.yuliuren.alicizaframework/ThirdParty/AnimationFlow/Editor/Styles";
if (!System.IO.File.Exists(projectPath + editorAssets + "/AnimationFlowStyles.uss")) {
var sdir = new System.IO.DirectoryInfo(Application.dataPath);
var dirQueue = new Queue<System.IO.DirectoryInfo>();
dirQueue.Enqueue(sdir);
bool found = false;
while (dirQueue.Count > 0) {
System.IO.DirectoryInfo dir = dirQueue.Dequeue();
if (System.IO.File.Exists(dir.FullName + "/AnimationFlowStyles.uss")) {
string path = dir.FullName.Replace('\\', '/');
found = true;
path = path.Replace(projectPath, "");
if (path.StartsWith("/")) {
path = path.Remove(0, 1);
}
editorAssets = path;
return true;
}
var dirs = dir.GetDirectories();
for (int i = 0; i < dirs.Length; i++) {
dirQueue.Enqueue(dirs[i]);
}
}
if (!found) {
Debug.LogWarning("Could not locate editor assets folder. Make sure you have imported the package correctly.");
return false;
}
}
return true;
}
}
}