Hi all,
I’ve got an InputActionMap to which I’m assigning to the devices list to restrict input to whatever device the user is currently using. On most platforms this all works fine, but it seems like on our Windows Steam build it falls over.
The InputActionMap has a binding to /start in it, like this:
actionMap = new InputActionMap("UI");
submit = actionMap.AddAction("Submit", InputActionType.Button);
submit.AddBinding("<Gamepad>/start");
submit.AddBinding("<Keyboard>/space");
submit.AddBinding("<Keyboard>/return");
//...
At runtime I’m detecting a change in input device, then doing this:
actionMap.devices = new(devices.ToArray()); //devices contains a reference to Keyboard
…and then I get this silly stuff in the log:
NullReferenceException while resolving binding 'Submit:<Gamepad>/start' in action map ' (UnityEngine.InputSystem.InputActionAsset):UI'
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
UnityEngine.InputSystem.InputBindingResolver:AddActionMap(InputActionMap) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputBindingResolver.cs:422)
UnityEngine.InputSystem.InputActionMap:ResolveBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1366)
UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1231)
UnityEngine.InputSystem.InputActionState:smile:eferredResolutionOfBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:4453)
UnityEngine.InputSystem.DeferBindingResolutionWrapper:smile:ispose() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionRebindingExtensions.cs:2810)
UnityEngine.InputSystem.InputActionState:ProcessControlStateChange(Int32, Int32, Int32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1525)
UnityEngine.InputSystem.InputActionState:UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged(InputControl, Double, InputEventPtr, Int64) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1326)
UnityEngine.InputSystem.InputManager:FireStateChangeNotifications(Int32, Double, InputEvent*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:380)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputUpdateType, Void*, UInt32, UInt32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputEvent*, InputUpdateType) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476)
UnityEngine.InputSystem.InputManager:OnUpdate(InputUpdateType, InputEventBuffer&) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120)
NullReferenceException: Object reference not set to an instance of an object.
at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap actionMap) [0x0030b] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputBindingResolver.cs:281
at UnityEngine.InputSystem.InputActionMap.ResolveBindings () [0x00170] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1366
at UnityEngine.InputSystem.InputActionMap.ResolveBindingsIfNecessary () [0x0004a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1231
at UnityEngine.InputSystem.InputActionState.DeferredResolutionOfBindings () [0x0009b] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:4453
at UnityEngine.InputSystem.InputActionRebindingExtensions+DeferBindingResolutionWrapper.Dispose () [0x00025] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionRebindingExtensions.cs:2810
at UnityEngine.InputSystem.InputActionState.ProcessControlStateChange (System.Int32 mapIndex, System.Int32 controlIndex, System.Int32 bindingIndex, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) [0x0032f] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1525
at UnityEngine.InputSystem.InputActionState.UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged (UnityEngine.InputSystem.InputControl control, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr, System.Int64 mapControlAndBindingIndex) [0x00016] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1326
at UnityEngine.InputSystem.InputManager.FireStateChangeNotifications (System.Int32 deviceIndex, System.Double internalTime, UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr) [0x000c8] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:380
at UnityEngine.InputSystem.InputManager.UpdateState (UnityEngine.InputSystem.InputDevice device, UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, System.Void* statePtr, System.UInt32 stateOffsetInDevice, System.UInt32 stateSize, System.Double internalTime, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) [0x000c4] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559
at UnityEngine.InputSystem.InputManager.UpdateState (UnityEngine.InputSystem.InputDevice device, UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr, UnityEngine.InputSystem.LowLevel.InputUpdateType updateType) [0x00112] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476
at UnityEngine.InputSystem.InputManager.OnUpdate (UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, UnityEngine.InputSystem.LowLevel.InputEventBuffer& eventBuffer) [0x0068a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291
at UnityEngine.InputSystem.LowLevel.NativeInputRuntime+<>c__DisplayClass7_0.<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType updateType, UnityEngineInternal.Input.NativeInputEventBuffer* eventBufferPtr) [0x0002a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65
at UnityEngineInternal.Input.NativeInputSystem.NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType updateType, System.IntPtr eventBuffer) [0x0002d] in C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.InputSystem.InputBindingResolver:AddActionMap(InputActionMap) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputBindingResolver.cs:424)
UnityEngine.InputSystem.InputActionMap:ResolveBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1366)
UnityEngine.InputSystem.InputActionMap:ResolveBindingsIfNecessary() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1231)
UnityEngine.InputSystem.InputActionState:smile:eferredResolutionOfBindings() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:4453)
UnityEngine.InputSystem.DeferBindingResolutionWrapper:smile:ispose() (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionRebindingExtensions.cs:2810)
UnityEngine.InputSystem.InputActionState:ProcessControlStateChange(Int32, Int32, Int32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1525)
UnityEngine.InputSystem.InputActionState:UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged(InputControl, Double, InputEventPtr, Int64) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1326)
UnityEngine.InputSystem.InputManager:FireStateChangeNotifications(Int32, Double, InputEvent*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:380)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputUpdateType, Void*, UInt32, UInt32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputEvent*, InputUpdateType) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476)
UnityEngine.InputSystem.InputManager:OnUpdate(InputUpdateType, InputEventBuffer&) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120)
Exception 'NullReferenceException' thrown from state change monitor 'InputActionState' on 'AnyKey:/Keyboard/anyKey'
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
UnityEngine.InputSystem.InputManager:FireStateChangeNotifications(Int32, Double, InputEvent*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:385)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputUpdateType, Void*, UInt32, UInt32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputEvent*, InputUpdateType) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476)
UnityEngine.InputSystem.InputManager:OnUpdate(InputUpdateType, InputEventBuffer&) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120)
NullReferenceException: Object reference not set to an instance of an object.
at UnityEngine.InputSystem.InputBindingResolver.AddActionMap (UnityEngine.InputSystem.InputActionMap actionMap) [0x0030b] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputBindingResolver.cs:281
at UnityEngine.InputSystem.InputActionMap.ResolveBindings () [0x00170] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1366
at UnityEngine.InputSystem.InputActionMap.ResolveBindingsIfNecessary () [0x0004a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionMap.cs:1231
at UnityEngine.InputSystem.InputActionState.DeferredResolutionOfBindings () [0x0009b] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:4453
at UnityEngine.InputSystem.InputActionRebindingExtensions+DeferBindingResolutionWrapper.Dispose () [0x00025] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionRebindingExtensions.cs:2810
at UnityEngine.InputSystem.InputActionState.ProcessControlStateChange (System.Int32 mapIndex, System.Int32 controlIndex, System.Int32 bindingIndex, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) [0x0032f] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1525
at UnityEngine.InputSystem.InputActionState.UnityEngine.InputSystem.LowLevel.IInputStateChangeMonitor.NotifyControlStateChanged (UnityEngine.InputSystem.InputControl control, System.Double time, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr, System.Int64 mapControlAndBindingIndex) [0x00016] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\Actions\InputActionState.cs:1326
at UnityEngine.InputSystem.InputManager.FireStateChangeNotifications (System.Int32 deviceIndex, System.Double internalTime, UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr) [0x000c8] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:380
at UnityEngine.InputSystem.InputManager.UpdateState (UnityEngine.InputSystem.InputDevice device, UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, System.Void* statePtr, System.UInt32 stateOffsetInDevice, System.UInt32 stateSize, System.Double internalTime, UnityEngine.InputSystem.LowLevel.InputEventPtr eventPtr) [0x000c4] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559
at UnityEngine.InputSystem.InputManager.UpdateState (UnityEngine.InputSystem.InputDevice device, UnityEngine.InputSystem.LowLevel.InputEvent* eventPtr, UnityEngine.InputSystem.LowLevel.InputUpdateType updateType) [0x00112] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476
at UnityEngine.InputSystem.InputManager.OnUpdate (UnityEngine.InputSystem.LowLevel.InputUpdateType updateType, UnityEngine.InputSystem.LowLevel.InputEventBuffer& eventBuffer) [0x0068a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291
at UnityEngine.InputSystem.LowLevel.NativeInputRuntime+<>c__DisplayClass7_0.<set_onUpdate>b__0 (UnityEngineInternal.Input.NativeInputUpdateType updateType, UnityEngineInternal.Input.NativeInputEventBuffer* eventBufferPtr) [0x0002a] in .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65
at UnityEngineInternal.Input.NativeInputSystem.NotifyUpdate (UnityEngineInternal.Input.NativeInputUpdateType updateType, System.IntPtr eventBuffer) [0x0002d] in C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
UnityEngine.InputSystem.InputManager:FireStateChangeNotifications(Int32, Double, InputEvent*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManagerStateMonitors.cs:387)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputUpdateType, Void*, UInt32, UInt32, Double, InputEventPtr) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3559)
UnityEngine.InputSystem.InputManager:UpdateState(InputDevice, InputEvent*, InputUpdateType) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3476)
UnityEngine.InputSystem.InputManager:OnUpdate(InputUpdateType, InputEventBuffer&) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\InputManager.cs:3291)
UnityEngine.InputSystem.LowLevel.<>c__DisplayClass7_0:<set_onUpdate>b__0(NativeInputUpdateType, NativeInputEventBuffer*) (at .\Library\PackageCache\com.unity.inputsystem@1.6.1\InputSystem\NativeInputRuntime.cs:65)
UnityEngineInternal.Input.NativeInputSystem:NotifyUpdate(NativeInputUpdateType, IntPtr) (at C:\build\output\unity\unity\Modules\Input\Private\Input.cs:120)
Crash!!!
So it looks like the Keyboard device doesn’t respond well to the /start binding. I’d assume that it would just ignore that binding and not cause problems, but it seems like that’s not the case.
Anybody else finding this? Am I doing something unfathomably stupid, or is this a bug in the InputSystem?
Thanks for your help!
Ben