79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
using Sirenix.OdinInspector.Editor;
|
|
using Sirenix.Utilities;
|
|
using Sirenix.Utilities.Editor;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using ET;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace ETEditor
|
|
{
|
|
public enum ToolKey
|
|
{
|
|
|
|
AB工具,
|
|
资源工具 ,
|
|
技能编辑器 ,
|
|
|
|
}
|
|
|
|
|
|
public class ToolEditor : OdinMenuEditorWindow
|
|
{
|
|
|
|
public readonly static Dictionary<ToolKey, string> toolDic = new Dictionary<ToolKey, string>(){
|
|
|
|
{ToolKey.AB工具,"Assets/Model/Cal/CalAssets/BulildAB.asset"},
|
|
{ToolKey.资源工具 ,"Assets/Model/Cal/CalAssets/ResTool.asset"},
|
|
{ToolKey.技能编辑器,"Assets/XNodeDemo/Skill/Skill And Modifier S Object.asset"},
|
|
};
|
|
[MenuItem("Tool Singlton/Tools Window #o"),]
|
|
private static void OpenEditor()
|
|
{
|
|
ToolEditor window = GetWindow<ToolEditor>();
|
|
window.position = GUIHelper.GetEditorWindowRect().AlignCenter(800, 700);
|
|
}
|
|
protected override OdinMenuTree BuildMenuTree()
|
|
{
|
|
OdinMenuTree tree = new OdinMenuTree(true);
|
|
foreach (var kp in toolDic)
|
|
{
|
|
tree.AddAssetAtPath(kp.Key.ToString(), kp.Value.Substring(kp.Value.IndexOf("Assets/")+7)).AddIcon(EditorIcons.Airplane);
|
|
}
|
|
//
|
|
// {ToolKey.技能编辑器,"Assets/XNodeDemo/Skill/Skill And Modifier S Object.asset"},
|
|
// var enumerable=tree.AddAllAssetsAtPath("技能列表", "XNodeDemo/Assets/Skill", typeof(SkillNodeGraph));
|
|
// foreach (var odinMenuItem in enumerable)
|
|
// {
|
|
// if (odinMenuItem.Value == null)
|
|
// {
|
|
// continue;
|
|
// }
|
|
//
|
|
// odinMenuItem.Name = odinMenuItem.Value.As<SkillNodeGraph>().Root.skillLogic.skillName;
|
|
// }
|
|
|
|
var list = new List<OdinMenuItem>();
|
|
DirectoryInfo directoryInfo = new DirectoryInfo("Assets/XNodeDemo/Assets/Skill");
|
|
foreach (var fileInfo in directoryInfo.GetFiles("*.asset"))
|
|
{
|
|
SkillNodeGraph skillNodeGraph =
|
|
AssetDatabase.LoadAssetAtPath<SkillNodeGraph>(Utility.Path.DataPathToAssetPath(fileInfo.FullName));
|
|
var odinItem = new OdinMenuItem(tree,$"{skillNodeGraph.Root.skillLogic.skillName}_{skillNodeGraph.Id}",skillNodeGraph);
|
|
list.Add(odinItem);
|
|
}
|
|
foreach (var odinMenuItem in list){
|
|
|
|
tree.AddMenuItemAtPath("技能列表",odinMenuItem);
|
|
}
|
|
|
|
return tree;
|
|
|
|
}
|
|
}
|
|
} |