Skip to content

Commit c5720d0

Browse files
Fix errors caused by using old InputManager functions while new InputSystem is active. (#4355)
1 parent 31bf040 commit c5720d0

File tree

2 files changed

+42
-13
lines changed

2 files changed

+42
-13
lines changed

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE
22
#define USE_INPUT_SYSTEM
33
using UnityEngine.InputSystem;
4-
using UnityEngine.InputSystem.Controls;
54
#endif
65

76
using System.Collections.Generic;
@@ -250,6 +249,30 @@ internal float GetAction(DebugAction action)
250249
return m_DebugActionStates[(int)action].actionState;
251250
}
252251

252+
internal bool GetActionToggleDebugMenuWithTouch()
253+
{
254+
#if USE_INPUT_SYSTEM
255+
var touches = InputSystem.EnhancedTouch.Touch.activeTouches;
256+
var touchCount = touches.Count;
257+
const InputSystem.TouchPhase touchPhaseBegan = InputSystem.TouchPhase.Began;
258+
#else
259+
var touches = Input.touches;
260+
var touchCount = Input.touchCount;
261+
const TouchPhase touchPhaseBegan = TouchPhase.Began;
262+
#endif
263+
if (touchCount == 3)
264+
{
265+
foreach (var touch in touches)
266+
{
267+
// Gesture: 3-finger double-tap
268+
if (touch.phase == touchPhaseBegan && touch.tapCount == 2)
269+
return true;
270+
}
271+
}
272+
273+
return false;
274+
}
275+
253276
void RegisterInputs()
254277
{
255278
#if UNITY_EDITOR

com.unity.render-pipelines.core/Runtime/Debugging/DebugUpdater.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
#if ENABLE_INPUT_SYSTEM && ENABLE_INPUT_SYSTEM_PACKAGE
2+
#define USE_INPUT_SYSTEM
3+
using UnityEngine.InputSystem;
4+
using UnityEngine.InputSystem.UI;
5+
using UnityEngine.InputSystem.EnhancedTouch;
6+
#endif
17
using UnityEngine.EventSystems;
28

39
namespace UnityEngine.Rendering
@@ -17,7 +23,17 @@ static void RuntimeInit()
1723
if (es == null)
1824
{
1925
go.AddComponent<EventSystem>();
26+
#if USE_INPUT_SYSTEM
27+
// FIXME: InputSystemUIInputModule has a quirk where the default actions fail to get initialized if the
28+
// component is initialized while the GameObject is active. So we deactivate it temporarily.
29+
// See https://fogbugz.unity3d.com/f/cases/1323566/
30+
go.SetActive(false);
31+
go.AddComponent<InputSystemUIInputModule>();
32+
go.SetActive(true);
33+
EnhancedTouchSupport.Enable();
34+
#else
2035
go.AddComponent<StandaloneInputModule>();
36+
#endif
2137
}
2238
DontDestroyOnLoad(go);
2339
}
@@ -28,21 +44,11 @@ void Update()
2844

2945
debugManager.UpdateActions();
3046

31-
if (debugManager.GetAction(DebugAction.EnableDebugMenu) != 0.0f)
47+
if (debugManager.GetAction(DebugAction.EnableDebugMenu) != 0.0f ||
48+
debugManager.GetActionToggleDebugMenuWithTouch())
3249
{
3350
debugManager.displayRuntimeUI = !debugManager.displayRuntimeUI;
3451
}
35-
else
36-
{
37-
if (Input.touchCount == 3)
38-
{
39-
foreach (var touch in Input.touches)
40-
{
41-
if (touch.phase == TouchPhase.Began)
42-
debugManager.displayRuntimeUI = !debugManager.displayRuntimeUI;
43-
}
44-
}
45-
}
4652

4753
if (debugManager.displayRuntimeUI && debugManager.GetAction(DebugAction.ResetAll) != 0.0f)
4854
{

0 commit comments

Comments
 (0)