47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
|
using System.IO;
|
||
|
using Game;
|
||
|
using Sirenix.OdinInspector;
|
||
|
using Sirenix.OdinInspector.Editor;
|
||
|
using UnityEditor;
|
||
|
using UnityEngine.Serialization;
|
||
|
|
||
|
namespace ZEditor
|
||
|
{
|
||
|
public class BuffEditor : OdinEditorWindow
|
||
|
{
|
||
|
[MenuItem("Game/Editor Buff Editor")]
|
||
|
static void GetWindow()
|
||
|
{
|
||
|
GetWindow<BuffEditor>("BuffEditor").Show();
|
||
|
}
|
||
|
|
||
|
[LabelText("路径")] [FolderPath] public string savePath = "Assets/Configs/Buff";
|
||
|
|
||
|
[LabelText("Buff配置")] [ReadOnly] public string title = "Buff配置";
|
||
|
[LabelText("基本属性")] public BuffConfig Buff = new BuffConfig();
|
||
|
|
||
|
[Button("保存Config")]
|
||
|
void SaveConfig()
|
||
|
{
|
||
|
if (!Directory.Exists(savePath))
|
||
|
Directory.CreateDirectory(savePath);
|
||
|
|
||
|
if (string.IsNullOrEmpty(Buff.Name))
|
||
|
return;
|
||
|
|
||
|
string path = $"{savePath}/{Buff.Name}.asset";
|
||
|
var config = CreateInstance<BuffConfigObject>();
|
||
|
config.config = Buff;
|
||
|
|
||
|
AssetDatabase.CreateAsset(config, path);
|
||
|
AssetDatabase.SaveAssets();
|
||
|
AssetDatabase.Refresh();
|
||
|
Refresh();
|
||
|
}
|
||
|
|
||
|
void Refresh()
|
||
|
{
|
||
|
Buff = new BuffConfig();
|
||
|
}
|
||
|
}
|
||
|
}
|