#if ENABLE_UIELEMENTS_MODULE && UNITY_ENABLE_CHECKS #define ENABLE_RENDERING_DEBUGGER_UI #endif #if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE #define USE_INPUT_SYSTEM using UnityEngine.InputSystem; #endif // Input support for Rendering Debugger using Input System Package namespace UnityEngine.Rendering { public sealed partial class DebugManager { const string k_EnableDebug = "Enable Debug"; const string k_ResetBtn = "Debug Reset"; const string k_DebugPreviousBtn = "Debug Previous"; const string k_DebugNextBtn = "Debug Next"; const string k_PersistentBtn = "Debug Persistent"; const string k_DPadHorizontal = "Debug Horizontal"; const string k_MultiplierBtn = "Debug Multiplier"; #if USE_INPUT_SYSTEM const string k_AnyTouch = "Any Touch"; readonly InputActionMap m_DebugMenuEnableActions = new InputActionMap("Debug Menu Enable Actions"); readonly InputActionMap m_DebugMenuActions = new InputActionMap("Debug Menu Actions"); InputAction m_MultiplierAction; internal void EnableInputCallbacks() { m_DebugMenuEnableActions.Enable(); } internal void DisableInputCallbacks() { m_DebugMenuEnableActions.Disable(); } void ToggleRuntimeUI() => displayRuntimeUI = !displayRuntimeUI; void RegisterDebugInputs() { var enableAction = m_DebugMenuEnableActions.AddAction(k_EnableDebug, type: InputActionType.Button); enableAction.AddCompositeBinding("ButtonWithOneModifier") .With("Modifier", "/rightStickPress") .With("Button", "/leftStickPress") .With("Modifier", "/leftCtrl") .With("Button", "/backspace"); enableAction.performed += _ => ToggleRuntimeUI(); var anyTouchAction = m_DebugMenuEnableActions.AddAction(k_AnyTouch, type: InputActionType.Button); anyTouchAction.AddBinding("/touch2/tap"); // touch2 means "third finger" anyTouchAction.performed += ctx => { // We want a three-finger double-tap to toggle the debug UI. However, it's a bit tricky to perform a // three-finger tap consistently. Therefore, to be slightly error-tolerant, we actually check for a // "double-tap action on the third tracked finger". var pressControl = ctx.control as InputSystem.Controls.ButtonControl; var touchControl = pressControl?.parent as InputSystem.Controls.TouchControl; int tapCount = touchControl?.tapCount?.ReadValue() ?? 0; if (tapCount == 2) ToggleRuntimeUI(); }; #if ENABLE_RENDERING_DEBUGGER_UI var resetAction = m_DebugMenuActions.AddAction(k_ResetBtn, type: InputActionType.Button); resetAction.AddCompositeBinding("ButtonWithOneModifier") .With("Modifier", "/rightStickPress") .With("Button", "/b") .With("Modifier", "/leftAlt") .With("Button", "/backspace"); resetAction.performed += _ => { Reset(); }; var next = m_DebugMenuActions.AddAction(k_DebugNextBtn, type: InputActionType.Button); next.AddBinding("/pageDown"); next.AddBinding("/rightShoulder"); next.performed += _ => { m_RuntimeDebugWindow.SelectNextPanel(); }; var previous = m_DebugMenuActions.AddAction(k_DebugPreviousBtn, type: InputActionType.Button); previous.AddBinding("/pageUp"); previous.AddBinding("/leftShoulder"); previous.performed += _ => { m_RuntimeDebugWindow.SelectPreviousPanel(); }; var persistentAction = m_DebugMenuActions.AddAction(k_PersistentBtn, type: InputActionType.Button); persistentAction.AddBinding("/rightShift"); persistentAction.AddBinding("/x"); persistentAction.performed += _ => { TogglePersistent(); }; m_MultiplierAction = m_DebugMenuActions.AddAction(k_MultiplierBtn, type: InputActionType.Value); m_MultiplierAction.AddBinding("/leftShift"); m_MultiplierAction.AddBinding("/y"); var moveHorizontalAction = m_DebugMenuActions.AddAction(k_DPadHorizontal); moveHorizontalAction.AddCompositeBinding("1DAxis") .With("Positive", "/dpad/right") .With("Negative", "/dpad/left") .With("Positive", "/rightArrow") .With("Negative", "/leftArrow"); moveHorizontalAction.performed += ctx => { bool multiplierPressed = m_MultiplierAction.IsPressed(); bool increment = ctx.ReadValue() > 0.0f; if (increment) { selectedWidget?.OnIncrement(multiplierPressed); } else { selectedWidget?.OnDecrement(multiplierPressed); } }; #endif } #endif } }