From 5cf5c6163f18e2ce3406bfc76e94e7b9737e01d6 Mon Sep 17 00:00:00 2001 From: jak Date: Fri, 13 Dec 2024 14:01:16 +0000 Subject: [PATCH 1/3] (InputStateWindow) Added null checks to 'DrawHexDump' to avoid null reference errors and subscribed to device changed events - closing the window when the device is disconnected (this is done to avoid cached state from hanging around on reconnect) --- .../Editor/Internal/InputStateWindow.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs index 8376792d48..a1f665df0a 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs @@ -113,6 +113,26 @@ public unsafe void InitializeWithControl(InputControl control) PollBuffersFromControl(control, selectBuffer: true); titleContent = new GUIContent(control.displayName); + + InputSystem.onDeviceChange += OnDeviceChange; + } + + private void OnDeviceChange(InputDevice device, InputDeviceChange change) + { + if (m_Control is null) + return; + + if (device.deviceId != m_Control.device.deviceId) + return; + + if (change == InputDeviceChange.Removed) + Close(); + } + + internal void OnDestroy() + { + if (m_Control != null) + InputSystem.onDeviceChange -= OnDeviceChange; } private unsafe void PollBuffersFromControl(InputControl control, bool selectBuffer = false) @@ -286,6 +306,12 @@ private string FormatByte(byte value) ////TODO: support dumping multiple state side-by-side when comparing private void DrawHexDump() { + if (m_StateBuffers is null) + return; + + if (m_StateBuffers[m_SelectedStateBuffer] is null) + return; + m_HexDumpScrollPosition = EditorGUILayout.BeginScrollView(m_HexDumpScrollPosition); var stateBuffer = m_StateBuffers[m_SelectedStateBuffer]; From 26146e9219eb1c687bd42539701e869943f03dc8 Mon Sep 17 00:00:00 2001 From: jak Date: Wed, 18 Dec 2024 10:54:32 +0000 Subject: [PATCH 2/3] Added changelog entry --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 2a36143974..26562242d1 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -34,6 +34,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed an issue with default device selection when adding new Control Scheme. - Fixed an issue where action map delegates were not updated when the asset already assigned to the PlayerInput component were changed [ISXB-711](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-711). - Fixed Action properties edition in the UI Toolkit version of the Input Actions Asset editor. [ISXB-1277](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1277) +- Fixed an editor crash caused by input debugger device state window reusing cached state when reconnecting Stadia controller. [ISXB-658](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-658) ### Changed - Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086). From 7751db0f15a497c7edc2113065c43140bce766fd Mon Sep 17 00:00:00 2001 From: jak Date: Wed, 18 Dec 2024 11:28:55 +0000 Subject: [PATCH 3/3] formatting --- .../InputSystem/Editor/Internal/InputStateWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs index a1f665df0a..bd095471b5 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs @@ -125,7 +125,7 @@ private void OnDeviceChange(InputDevice device, InputDeviceChange change) if (device.deviceId != m_Control.device.deviceId) return; - if (change == InputDeviceChange.Removed) + if (change == InputDeviceChange.Removed) Close(); }