Context: I am creating an app that will allow users to place, move, and modify objects. Because of the nature of the app, I have undo and redo functionality setup with the standard ctrl+z and ctrl+shift+z shortcuts. This is typically an issue because when you press ctrl+shift+z, the input system will trigger any actions that use any combination of those keys. In my case both undo and redo are triggered when I just wanted redo. I was able to fix that problem by enabling Input Consumption in the project settings. But, as is typical, yesterday’s solution is today’s problem.
Problem: Now I am trying to implement cancel functionality for the tools in the app. For example I have a move tool that allows you to grab an object and drag it by clicking and holding the mouse button and when you release the mouse button you drop the object in the new position (cancel would just send it back to where it was). this is where input consumption comes back to bite me. when you are holding an object (holding the mouse button) all other inputs are ignored meaning the only time you can cancel the use of a tool is when you aren’t actively using the tool.
My Potential Solution: The solution I have in my head is to disable input consumption and create some sort of shortcut manager that will be in charge of making sure that I don’t call multiple shortcuts. Basically implementing my own form of input consumption for only certain actions (the shortcuts).
If anybody has a better or simpler solution I would love to hear it.
Edit: For anybody who finds this in the future. My problem was of my own making and not because of the input consumption setting. Only inputs with shared keys are consumed. i.e if I use ctrl+z and shift+ctrl+z, when I press shift+ctrl+z, Unity will ignore the fact that I pressed ctrl+z. But since I don’t use escape and the mouse button together anywhere, the cancel action is still performed when the mouse button is held meaning the input is not consumed.