Skip to content

Commit 6f82e69

Browse files
committed
FIX: Added code to attempt resolving control when set to use current device and control have not been previously resolved. Needed since the is no callback when it changes.
1 parent e2778c9 commit 6f82e69

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Assets/Samples/Visualizers/InputControlVisualizer.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ private static InputControl ResolveCurrentControl(InputControlList<InputControl>
154154
// Only accept control that belongs to the current device of the same device type as candidate control device type.
155155
foreach (var candidate in candidates)
156156
{
157-
if (candidate.device == GetCurrentDevice(candidate.device))
158-
{
157+
var currentDevice = GetCurrentDevice(candidate.device);
158+
if (candidate.device == currentDevice)
159159
return candidate;
160-
}
161160
}
161+
162162
return null;
163163
}
164164

@@ -182,6 +182,13 @@ private void ResolveControl()
182182
SetupVisualizer();
183183
}
184184

185+
void Update()
186+
{
187+
// There is currently no callback when current device changes so we will reattempt to resolve control
188+
if (m_UseCurrentDevice && m_Control == null)
189+
ResolveControl();
190+
}
191+
185192
private static InputDevice GetCurrentDevice(InputDevice device)
186193
{
187194
if (device is Gamepad) return Gamepad.current;

0 commit comments

Comments
 (0)