My game has its own update loop for deterministic networked logic, thus the need for the InputSystem to be updated manually each frame of my custom update function. I should have set everything up properly:
1. Set ‘Process Events Manually’
2. Call ‘InputSystem.Update’ in my custom update function
However, I find that input events aren’t being fired. I suspect that the problem could lie with Unity’s Input System itself, because running my code but with the setting ‘Process Events in Dynamic Update’ enabled instead allows the input events to fire and everything to work properly, leading me to believe that ‘Process Events Manually’ and the ‘InputSystem.Update()’ method might not be working as intended.
According to this old forum post , a Unity developer himself confirms that what I have tried should be how it works*, with the only difference being that ‘InputSystem.Update(InputUpdateType.Manual)’ is called instead of simply ‘InputSystem.Update()’. However, this isn’t possible anymore. Looking at the source code, the parameter version of InputSystem.Update is now internal, not public, so I can’t call it:
*technically, he comments that it is broken at that time. However, looking at the ticket he filed, it is announced later that the bug is fixed and it should be working now.
‘Process Events Manually’ and the ‘InputSystem.Update()’ method works as intended in my testing. My immediate thought is that it’s an issue with script execution order. You want to make sure that the script that updates the input system is run before ‘Default Time’ and ‘UnityEngine.InputSystem.PlayerInput’. Also, make sure that the input system is only updated once per frame.
Keep in mind that the documentation advises against updating the input system manually as it might lead to unintended behaviour. An example of this that I’ve run into is that Unity’s event system navigation will break entirely, so unless you’re using your own system for UI navigation you will run into issues there.
I’m using the auto generated C# class, and calling methods like IsPressed(), IsInProgress(), WasPerformedThisFrame(), etc. That’s the polling API right.
So based on what you’ve said, if I want manual updating to work, I should instead use the PlayerInput component with its behaviour set to Invoke C#/Unity events, and ensure the script execution order is correct.
That right! Although you don’t necessarily have to use the PlayerInput component. You can just subscribe to the events you want to listen to in same script where you called “IsPressed()” etc. before.
I’m not sure what’s happening in your case but I also update InputSystem manually and it appears to be working normally. I call InputSystem.settings.updateMode = InputSettings.UpdateMode.ProcessEventsManually; when the game starts but this should do the same thing as setting Update Mode in the editor GUI.
The other difference is that I’m calling InputSystem.Update() during the ScriptRunBehaviourUpdate phase of the PlayerLoop, i.e., when Update() is called on scripts and when InputSystem’s dynamic update option would trigger updates. My use case here was to set up per-frame state, process the event stream from InputSystem, then continue with per-frame processing.
I’m also using the auto generated C# class. So far I haven’t run into any issues with callbacks or polling not working.