This commit is contained in:
2026-04-25 23:37:10 +02:00
commit 19d6bd934a
476 changed files with 9198 additions and 0 deletions
@@ -0,0 +1,78 @@
using System.Linq;
using RPGCore.SceneModules.PathVisualizerSceneModule;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace RPGCore.Editor.Drawers.SceneModules.PathVisualizer
{
[CustomPropertyDrawer(typeof(PathVisualizerModule))]
public class PathVisualizerModuleDrawer : PropertyDrawer
{
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
root.Add(new PropertyField(property));
if (EditorApplication.isPlaying)
{
root.Add(CreateList(property));
}
else
{
root.Add(new HelpBox("Subscribed events preview available only in play mode.", HelpBoxMessageType.Info));
}
return root;
}
private VisualElement CreateList(SerializedProperty property)
{
var wrapper = new VisualElement();
var helpBox = new HelpBox();
helpBox.text = "Usable only runtime via script.<br>Below is list of currently managed paths.";
helpBox.messageType = HelpBoxMessageType.Info;
helpBox.style.marginTop = 15;
wrapper.Add(helpBox);
var list = new VisualElement();
list.schedule.Execute(() => RefreshList(property, list)).Every(2500);
list.Add(new Label("List empty."));
wrapper.Add(list);
RefreshList(property, list);
return wrapper;
}
private void RefreshList(SerializedProperty property, VisualElement list)
{
var pathVisualizers = (property.boxedValue as PathVisualizerModule).pathVisualizers;
// No elements, only label with info
if (pathVisualizers.Count == 0 && list.Children().FirstOrDefault() is Label) return;
// Nothing changed
if (pathVisualizers.Count == list.childCount && list.Children().FirstOrDefault() is not Label) return;
list.Clear();
if (!pathVisualizers.Any())
{
list.Add(new Label("List empty."));
return;
}
foreach (var pathVisualizer in pathVisualizers)
{
if (!pathVisualizer) continue;
var objectField = new ObjectField();
objectField.value = pathVisualizer;
objectField.SetEnabled(false);
list.Add(objectField);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 774f2a8b09b7472c982b804adde32e41
timeCreated: 1761839859