Files
AppleHillsProduction/Assets/Editor/TimelineEventMappingDrawer.cs
tschesky 10992b43cc Unity Timeline Interaction System Integration (#17)
- Added InteractionTimelineAction component for timeline-driven interactions
- Implemented custom editor for timeline event mapping
- Updated interaction event flow to support timeline actions
- Enhanced character move target configuration
- Improved inspector UI for interactable components
- Added technical documentation for interaction system
- Refactored interaction action base classes for extensibility
- Fixed issues with character binding in timelines

Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com>
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: #17
2025-10-07 10:57:11 +00:00

49 lines
2.1 KiB
C#

using UnityEngine;
using UnityEditor;
using Interactions;
using System;
[CustomPropertyDrawer(typeof(InteractionTimelineAction.TimelineEventMapping))]
public class TimelineEventMappingDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// Use default property drawer, but initialize values if needed
InitializeDefaultValues(property);
EditorGUI.PropertyField(position, property, label, true);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
// Called when property is created to initialize default values
private void InitializeDefaultValues(SerializedProperty property)
{
// Check if this is a new/empty property that needs initialization
SerializedProperty timelinesArray = property.FindPropertyRelative("timelines");
if (timelinesArray != null && timelinesArray.arraySize == 0)
{
// This appears to be a new property, so initialize default values
// Initialize timelines array with one empty element
timelinesArray.ClearArray();
timelinesArray.InsertArrayElementAtIndex(0);
timelinesArray.GetArrayElementAtIndex(0).objectReferenceValue = null;
// Set default binding values
property.FindPropertyRelative("bindPlayerCharacter").boolValue = true;
property.FindPropertyRelative("bindPulverCharacter").boolValue = true;
property.FindPropertyRelative("playerTrackName").stringValue = "Player";
property.FindPropertyRelative("pulverTrackName").stringValue = "Pulver";
property.FindPropertyRelative("timeoutSeconds").floatValue = 30f;
property.FindPropertyRelative("loopLast").boolValue = false;
property.FindPropertyRelative("loopAll").boolValue = false;
// Make sure to apply modifications
property.serializedObject.ApplyModifiedProperties();
}
}
}