2025-12-15 09:20:15 +00:00
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using Items;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Editor
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Custom editor for ControllerSwitchItem that shows only relevant fields based on camera switch mode.
|
|
|
|
|
|
/// </summary>
|
2025-12-19 15:26:13 +01:00
|
|
|
|
[CustomEditor(typeof(ControllerSwitchItem), true)]
|
2025-12-15 09:20:15 +00:00
|
|
|
|
public class ControllerSwitchItemEditor : UnityEditor.Editor
|
|
|
|
|
|
{
|
2025-12-19 15:26:13 +01:00
|
|
|
|
protected SerializedProperty _targetControllerName;
|
|
|
|
|
|
protected SerializedProperty _visualRepresentation;
|
2025-12-15 09:20:15 +00:00
|
|
|
|
|
|
|
|
|
|
// Base class properties
|
2025-12-19 15:26:13 +01:00
|
|
|
|
protected SerializedProperty _isOneTime;
|
|
|
|
|
|
protected SerializedProperty _cooldown;
|
|
|
|
|
|
protected SerializedProperty _characterToInteract;
|
|
|
|
|
|
|
|
|
|
|
|
// Base interactable events
|
|
|
|
|
|
protected SerializedProperty _interactionStarted;
|
|
|
|
|
|
protected SerializedProperty _interactionInterrupted;
|
|
|
|
|
|
protected SerializedProperty _characterArrived;
|
|
|
|
|
|
protected SerializedProperty _interactionComplete;
|
2025-12-15 09:20:15 +00:00
|
|
|
|
|
2025-12-19 15:26:13 +01:00
|
|
|
|
protected virtual void OnEnable()
|
2025-12-15 09:20:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
// Controller Switch Settings
|
|
|
|
|
|
_targetControllerName = serializedObject.FindProperty("targetControllerName");
|
|
|
|
|
|
_visualRepresentation = serializedObject.FindProperty("visualRepresentation");
|
|
|
|
|
|
|
|
|
|
|
|
// Base class properties
|
|
|
|
|
|
_isOneTime = serializedObject.FindProperty("isOneTime");
|
|
|
|
|
|
_cooldown = serializedObject.FindProperty("cooldown");
|
|
|
|
|
|
_characterToInteract = serializedObject.FindProperty("characterToInteract");
|
2025-12-19 15:26:13 +01:00
|
|
|
|
|
|
|
|
|
|
// Base interactable events
|
|
|
|
|
|
_interactionStarted = serializedObject.FindProperty("interactionStarted");
|
|
|
|
|
|
_interactionInterrupted = serializedObject.FindProperty("interactionInterrupted");
|
|
|
|
|
|
_characterArrived = serializedObject.FindProperty("characterArrived");
|
|
|
|
|
|
_interactionComplete = serializedObject.FindProperty("interactionComplete");
|
2025-12-15 09:20:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
serializedObject.Update();
|
|
|
|
|
|
|
|
|
|
|
|
// Draw script field (read-only)
|
|
|
|
|
|
EditorGUI.BeginDisabledGroup(true);
|
|
|
|
|
|
EditorGUILayout.ObjectField("Script", MonoScript.FromMonoBehaviour((MonoBehaviour)target), GetType(), false);
|
|
|
|
|
|
EditorGUI.EndDisabledGroup();
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
|
|
|
|
// Interaction Settings (from base class)
|
|
|
|
|
|
EditorGUILayout.LabelField("Interaction Settings", EditorStyles.boldLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_isOneTime);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_cooldown);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_characterToInteract);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
|
|
|
|
// Controller Switch Settings
|
|
|
|
|
|
EditorGUILayout.LabelField("Controller Switch Settings", EditorStyles.boldLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_targetControllerName);
|
|
|
|
|
|
|
2025-12-19 15:26:13 +01:00
|
|
|
|
if (string.IsNullOrEmpty(_targetControllerName.stringValue))
|
2025-12-15 09:20:15 +00:00
|
|
|
|
{
|
2025-12-19 15:26:13 +01:00
|
|
|
|
EditorGUILayout.HelpBox("Assign a target controller name (must match registration name in InputManager).", MessageType.Warning);
|
2025-12-15 09:20:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
|
|
|
|
// Visual Feedback
|
|
|
|
|
|
EditorGUILayout.LabelField("Visual Feedback", EditorStyles.boldLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_visualRepresentation);
|
2025-12-19 15:26:13 +01:00
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
|
|
|
|
|
|
// Base Interactable Events
|
|
|
|
|
|
EditorGUILayout.LabelField("Interaction Events", EditorStyles.boldLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_interactionStarted);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_interactionInterrupted);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_characterArrived);
|
|
|
|
|
|
EditorGUILayout.PropertyField(_interactionComplete);
|
|
|
|
|
|
|
|
|
|
|
|
DrawCustomFields();
|
2025-12-15 09:20:15 +00:00
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
|
}
|
2025-12-19 15:26:13 +01:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Override this in derived editors to add custom fields specific to derived classes
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
protected virtual void DrawCustomFields()
|
|
|
|
|
|
{
|
|
|
|
|
|
// Base class has no additional custom fields
|
|
|
|
|
|
}
|
2025-12-15 09:20:15 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|