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). diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs index 8376792d48..bd095471b5 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];