iFactory.Cutting.Unity/Assets/BITKit/Unity/Scripts/Utils/UnityApplicationFile.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2024-03-04 18:45:21 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace BITKit.IO
{
public class UnityApplicationFile : MonoBehaviour
{
[SerializeReference,SubclassSelector] internal IApplicationFile service;
}
#if UNITY_EDITOR
[CustomEditor(typeof(UnityApplicationFile))]
public sealed class UnityApplicationFileInspector:BITInspector<UnityApplicationFile>
{
public override VisualElement CreateInspectorGUI()
{
FillDefaultInspector();
CreateSubTitle("Editor");
if (agent.service is null)
{
root.Create<Label>().text = "Service is null";
return root;
}
var current = agent.service.Current;
var saveButton = root.Create<Button>();
saveButton.text = "Save";
saveButton.clicked += agent.service.Save;
var loadButton = root.Create<Button>();
loadButton.text = "Load";
loadButton.clicked += ()=>agent.service.Load();
var currentPathLabel = root.Create<Label>();
currentPathLabel.text = current?.GetPath() ?? "No File";
var reloadButton = root.Create<Button>();
reloadButton.text = "Reload";
reloadButton.clicked += agent.service.Reload;
return root;
}
}
#endif
}