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