init
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
using System.Linq;
|
||||
using RPGCore.StatusEffect.ObjectModules.StatusObjectModule;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace RPGCore.StatusEffect.Editor.Drawers
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(StatusModule))]
|
||||
public class StatusModuleDrawer : PropertyDrawer
|
||||
{
|
||||
public override VisualElement CreatePropertyGUI(SerializedProperty property)
|
||||
{
|
||||
var root = new VisualElement();
|
||||
|
||||
if (Application.isPlaying) root.Add(CreateDebugBox(property));
|
||||
root.Add(new PropertyField(property));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private HelpBox CreateDebugBox(SerializedProperty property)
|
||||
{
|
||||
var debugBox = new HelpBox();
|
||||
debugBox.style.flexDirection = FlexDirection.Column;
|
||||
debugBox.style.alignItems = Align.Stretch;
|
||||
debugBox.SetEnabled(false);
|
||||
|
||||
debugBox.Add(new Label("RUNTIME DEBUG:"));
|
||||
|
||||
var statusList = new VisualElement();
|
||||
debugBox.Add(statusList);
|
||||
|
||||
debugBox.schedule.Execute(() =>
|
||||
{
|
||||
var module = property.boxedValue as StatusModule;
|
||||
|
||||
statusList.Clear();
|
||||
foreach (var status in module.statuses)
|
||||
statusList.Add(new Label(status.definition.name));
|
||||
}).Every(100);
|
||||
|
||||
return debugBox;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user