Skip to content

Commit 0cbfdfe

Browse files
Secticideekcoh
andauthored
FIX: Input State Window is now force-closed when the device it is inspecting is disconnected (#2093)
Co-authored-by: Håkan Sidenvall <[email protected]>
1 parent 6dae5a3 commit 0cbfdfe

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ however, it has to be formatted properly to pass verification tests.
3434
- Fixed an issue with default device selection when adding new Control Scheme.
3535
- 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).
3636
- 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)
37+
- 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)
3738
- Fixed an issue where batch jobs would fail with "Error: Error building Player because scripts are compiling" if a source generated .inputactions asset is out of sync with its generated source code (ISXB-1300).
3839
- Fixed multiple `OnScreenStick` Components that does not work together when using them simultaneously in isolation mode. [ISXB-813](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-813)
3940

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ public unsafe void InitializeWithControl(InputControl control)
113113
PollBuffersFromControl(control, selectBuffer: true);
114114

115115
titleContent = new GUIContent(control.displayName);
116+
117+
InputSystem.onDeviceChange += OnDeviceChange;
118+
}
119+
120+
private void OnDeviceChange(InputDevice device, InputDeviceChange change)
121+
{
122+
if (m_Control is null)
123+
return;
124+
125+
if (device.deviceId != m_Control.device.deviceId)
126+
return;
127+
128+
if (change == InputDeviceChange.Removed)
129+
Close();
130+
}
131+
132+
internal void OnDestroy()
133+
{
134+
if (m_Control != null)
135+
InputSystem.onDeviceChange -= OnDeviceChange;
116136
}
117137

118138
private unsafe void PollBuffersFromControl(InputControl control, bool selectBuffer = false)
@@ -286,6 +306,12 @@ private string FormatByte(byte value)
286306
////TODO: support dumping multiple state side-by-side when comparing
287307
private void DrawHexDump()
288308
{
309+
if (m_StateBuffers is null)
310+
return;
311+
312+
if (m_StateBuffers[m_SelectedStateBuffer] is null)
313+
return;
314+
289315
m_HexDumpScrollPosition = EditorGUILayout.BeginScrollView(m_HexDumpScrollPosition);
290316

291317
var stateBuffer = m_StateBuffers[m_SelectedStateBuffer];

0 commit comments

Comments
 (0)