using UnityEditor; using UnityEngine; using Items; namespace Editor { /// /// Custom editor for ControllerSwitchItem that shows only relevant fields based on camera switch mode. /// [CustomEditor(typeof(ControllerSwitchItem), true)] public class ControllerSwitchItemEditor : UnityEditor.Editor { protected SerializedProperty _targetControllerName; protected SerializedProperty _visualRepresentation; // Base class properties protected SerializedProperty _isOneTime; protected SerializedProperty _cooldown; protected SerializedProperty _characterToInteract; // Base interactable events protected SerializedProperty _interactionStarted; protected SerializedProperty _interactionInterrupted; protected SerializedProperty _characterArrived; protected SerializedProperty _interactionComplete; protected virtual void OnEnable() { // 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"); // Base interactable events _interactionStarted = serializedObject.FindProperty("interactionStarted"); _interactionInterrupted = serializedObject.FindProperty("interactionInterrupted"); _characterArrived = serializedObject.FindProperty("characterArrived"); _interactionComplete = serializedObject.FindProperty("interactionComplete"); } 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); if (string.IsNullOrEmpty(_targetControllerName.stringValue)) { EditorGUILayout.HelpBox("Assign a target controller name (must match registration name in InputManager).", MessageType.Warning); } EditorGUILayout.Space(); // Visual Feedback EditorGUILayout.LabelField("Visual Feedback", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_visualRepresentation); EditorGUILayout.Space(); // Base Interactable Events EditorGUILayout.LabelField("Interaction Events", EditorStyles.boldLabel); EditorGUILayout.PropertyField(_interactionStarted); EditorGUILayout.PropertyField(_interactionInterrupted); EditorGUILayout.PropertyField(_characterArrived); EditorGUILayout.PropertyField(_interactionComplete); DrawCustomFields(); serializedObject.ApplyModifiedProperties(); } /// /// Override this in derived editors to add custom fields specific to derived classes /// protected virtual void DrawCustomFields() { // Base class has no additional custom fields } } }