using AlicizaX.UI.Runtime; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace UnityEditor.UI { [CustomEditor(typeof(HotkeyComponent), true)] public class HotkeyComponentEditor : UnityEditor.Editor { private SerializedProperty _hotkeyAction; private SerializedProperty _hotkeyPressType; private SerializedProperty _component; private void OnEnable() { _component = serializedObject.FindProperty("_component"); _hotkeyAction = serializedObject.FindProperty("_hotkeyAction"); _hotkeyPressType = serializedObject.FindProperty("_hotkeyPressType"); } public override void OnInspectorGUI() { serializedObject.Update(); HotkeyComponent hotkeyComponent = (HotkeyComponent)target; EditorGUILayout.HelpBox( "Hotkeys auto-register to the nearest UIHolderObjectBase at runtime.", MessageType.Info ); if (hotkeyComponent.GetComponentInParent(true) == null) { EditorGUILayout.HelpBox( "No UIHolderObjectBase was found in parents. This hotkey will not register at runtime.", MessageType.Warning ); } if (_component.objectReferenceValue == null) { EditorGUILayout.HelpBox("No submit target was found on this object.", MessageType.Error); if (hotkeyComponent.TryGetComponent(typeof(ISubmitHandler), out Component submitHandler)) { _component.objectReferenceValue = submitHandler; } } using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox)) { EditorGUILayout.LabelField("Hotkey Setting", EditorStyles.boldLabel); EditorGUI.BeginDisabledGroup(true); EditorGUILayout.PropertyField(_component, new GUIContent("Component")); EditorGUI.EndDisabledGroup(); EditorGUILayout.PropertyField(_hotkeyAction, new GUIContent("Input Action")); EditorGUILayout.PropertyField(_hotkeyPressType, new GUIContent("Press Type")); } serializedObject.ApplyModifiedProperties(); } } }