Files
Bachelor-Arbeit-Thomas-Wichert/Assets/Convai/Scripts/Editor/NarrativeDesign/NarrativeDesignSectionChangeEventsDataPropertyDrawer.cs
2025-07-21 09:11:14 +02:00

43 lines
2.0 KiB
C#

using Convai.Scripts.Narrative_Design.Models;
using UnityEditor;
using UnityEngine;
namespace Convai.Scripts.Narrative_Design.Editor
{
[CustomPropertyDrawer(typeof(SectionChangeEventsData))]
public class NarrativeDesignSectionChangeEventsDataPropertyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
SerializedProperty sectionIdProperty = property.FindPropertyRelative("id");
SerializedProperty onSectionStartProperty = property.FindPropertyRelative("onSectionStart");
SerializedProperty onSectionEndProperty = property.FindPropertyRelative("onSectionEnd");
Rect sectionIdRect = new(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);
EditorGUI.LabelField(sectionIdRect, "Section ID", sectionIdProperty.stringValue);
position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, onSectionStartProperty, true);
position.y += EditorGUI.GetPropertyHeight(onSectionStartProperty) + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(position, onSectionEndProperty, true);
EditorGUI.EndProperty();
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
SerializedProperty onSectionStartProperty = property.FindPropertyRelative("onSectionStart");
SerializedProperty onSectionEndProperty = property.FindPropertyRelative("onSectionEnd");
float height = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(onSectionStartProperty) + EditorGUIUtility.standardVerticalSpacing;
height += EditorGUI.GetPropertyHeight(onSectionEndProperty);
return height;
}
}
}