Files
TheVVaS-Assets/RPGCore.StatusEffect/Editor/Drawers/StatusModuleDrawer.cs
T
2026-04-25 23:37:10 +02:00

47 lines
1.4 KiB
C#

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;
}
}
}