1
This commit is contained in:
50
Src/Unity/Scripts/Utils/UnityApplicationFile.cs
Normal file
50
Src/Unity/Scripts/Utils/UnityApplicationFile.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user