Skip to content

Commit 783431b

Browse files
arttu-peltonenEvergreen
authored andcommitted
Keep debug menu input actions disabled until the debug UI is open
1 parent 495eb86 commit 783431b

2 files changed

Lines changed: 23 additions & 13 deletions

File tree

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugManager.Input.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,32 +23,33 @@ public sealed partial class DebugManager
2323
#if USE_INPUT_SYSTEM
2424
const string k_AnyTouch = "Any Touch";
2525

26-
readonly InputActionMap m_DebugActionMap = new InputActionMap("Debug Menu");
26+
readonly InputActionMap m_DebugMenuEnableActions = new InputActionMap("Debug Menu Enable Actions");
27+
readonly InputActionMap m_DebugMenuActions = new InputActionMap("Debug Menu Actions");
2728
InputAction m_MultiplierAction;
2829

2930
internal void EnableInputCallbacks()
3031
{
31-
m_DebugActionMap.Enable();
32+
m_DebugMenuEnableActions.Enable();
3233
}
3334

3435
internal void DisableInputCallbacks()
3536
{
36-
m_DebugActionMap.Disable();
37+
m_DebugMenuEnableActions.Disable();
3738
}
3839

3940
void ToggleRuntimeUI() => displayRuntimeUI = !displayRuntimeUI;
4041

4142
void RegisterDebugInputs()
4243
{
43-
var enableAction = m_DebugActionMap.AddAction(k_EnableDebug, type: InputActionType.Button);
44+
var enableAction = m_DebugMenuEnableActions.AddAction(k_EnableDebug, type: InputActionType.Button);
4445
enableAction.AddCompositeBinding("ButtonWithOneModifier")
4546
.With("Modifier", "<Gamepad>/rightStickPress")
4647
.With("Button", "<Gamepad>/leftStickPress")
4748
.With("Modifier", "<Keyboard>/leftCtrl")
4849
.With("Button", "<Keyboard>/backspace");
4950
enableAction.performed += _ => ToggleRuntimeUI();
5051

51-
var anyTouchAction = m_DebugActionMap.AddAction(k_AnyTouch, type: InputActionType.Button);
52+
var anyTouchAction = m_DebugMenuEnableActions.AddAction(k_AnyTouch, type: InputActionType.Button);
5253
anyTouchAction.AddBinding("<Touchscreen>/touch2/tap"); // touch2 means "third finger"
5354
anyTouchAction.performed += ctx =>
5455
{
@@ -63,34 +64,34 @@ void RegisterDebugInputs()
6364
};
6465

6566
#if ENABLE_RENDERING_DEBUGGER_UI
66-
var resetAction = m_DebugActionMap.AddAction(k_ResetBtn, type: InputActionType.Button);
67+
var resetAction = m_DebugMenuActions.AddAction(k_ResetBtn, type: InputActionType.Button);
6768
resetAction.AddCompositeBinding("ButtonWithOneModifier")
6869
.With("Modifier", "<Gamepad>/rightStickPress")
6970
.With("Button", "<Gamepad>/b")
7071
.With("Modifier", "<Keyboard>/leftAlt")
7172
.With("Button", "<Keyboard>/backspace");
7273
resetAction.performed += _ => { Reset(); };
7374

74-
var next = m_DebugActionMap.AddAction(k_DebugNextBtn, type: InputActionType.Button);
75+
var next = m_DebugMenuActions.AddAction(k_DebugNextBtn, type: InputActionType.Button);
7576
next.AddBinding("<Keyboard>/pageDown");
7677
next.AddBinding("<Gamepad>/rightShoulder");
7778
next.performed += _ => { m_RuntimeDebugWindow.SelectNextPanel(); };
7879

79-
var previous = m_DebugActionMap.AddAction(k_DebugPreviousBtn, type: InputActionType.Button);
80+
var previous = m_DebugMenuActions.AddAction(k_DebugPreviousBtn, type: InputActionType.Button);
8081
previous.AddBinding("<Keyboard>/pageUp");
8182
previous.AddBinding("<Gamepad>/leftShoulder");
8283
previous.performed += _ => { m_RuntimeDebugWindow.SelectPreviousPanel(); };
8384

84-
var persistentAction = m_DebugActionMap.AddAction(k_PersistentBtn, type: InputActionType.Button);
85+
var persistentAction = m_DebugMenuActions.AddAction(k_PersistentBtn, type: InputActionType.Button);
8586
persistentAction.AddBinding("<Keyboard>/rightShift");
8687
persistentAction.AddBinding("<Gamepad>/x");
8788
persistentAction.performed += _ => { TogglePersistent(); };
8889

89-
m_MultiplierAction = m_DebugActionMap.AddAction(k_MultiplierBtn, type: InputActionType.Value);
90+
m_MultiplierAction = m_DebugMenuActions.AddAction(k_MultiplierBtn, type: InputActionType.Value);
9091
m_MultiplierAction.AddBinding("<Keyboard>/leftShift");
9192
m_MultiplierAction.AddBinding("<Gamepad>/y");
9293

93-
var moveHorizontalAction = m_DebugActionMap.AddAction(k_DPadHorizontal);
94+
var moveHorizontalAction = m_DebugMenuActions.AddAction(k_DPadHorizontal);
9495
moveHorizontalAction.AddCompositeBinding("1DAxis")
9596
.With("Positive", "<Gamepad>/dpad/right")
9697
.With("Negative", "<Gamepad>/dpad/left")
@@ -102,11 +103,11 @@ void RegisterDebugInputs()
102103
bool increment = ctx.ReadValue<float>() > 0.0f;
103104
if (increment)
104105
{
105-
selectedWidget.OnIncrement(multiplierPressed);
106+
selectedWidget?.OnIncrement(multiplierPressed);
106107
}
107108
else
108109
{
109-
selectedWidget.OnDecrement(multiplierPressed);
110+
selectedWidget?.OnDecrement(multiplierPressed);
110111
}
111112
};
112113
#endif

Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugManager.UIState.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#if ENABLE_UIELEMENTS_MODULE && (UNITY_EDITOR || DEVELOPMENT_BUILD)
22
#define ENABLE_RENDERING_DEBUGGER_UI
33
#endif
4+
#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE
5+
#define USE_INPUT_SYSTEM
6+
#endif
47

58
using System;
69

@@ -99,6 +102,9 @@ public bool displayRuntimeUI
99102
m_RuntimeDebugWindow = go.AddComponent<RuntimeDebugWindow>();
100103
go.SetActive(true);
101104
}
105+
#if USE_INPUT_SYSTEM
106+
m_DebugMenuActions.Enable();
107+
#endif
102108
}
103109
else
104110
{
@@ -107,6 +113,9 @@ public bool displayRuntimeUI
107113
CoreUtils.Destroy(m_RuntimeDebugWindow.gameObject);
108114
m_RuntimeDebugWindow = null;
109115
}
116+
#if USE_INPUT_SYSTEM
117+
m_DebugMenuActions.Disable();
118+
#endif
110119
}
111120

112121
onDisplayRuntimeUIChanged(value);

0 commit comments

Comments
 (0)