Input state machine?

Consider these pseudo-pseudocode examples;

  • If the mouse is over an interactive object AND my “DoStuff” input axis is pressed, then interact with the object.
  • But if the mouse is NOT over an interactive object AND the “DoStuff” input axis is pressed, then enter the “NonInteractiveMode” state.
  • If we are in the “NonInteractiveMode” state, then dont even bother with the first 2 “if” tests and instead test some other tree of ifs.
    …

I have lots of such kind of complex combinations of input axes and lots of nested if/else situations to handle in my project.

What is the intended use of Unity; is there some built in feature in Unity that can handle this complexity for me? Or do I need to create my own InputHandler / StateManager game objects and have them keep track of input states and nested input situation? Or is there some other solution how this kind of problem is usually solved?

You’ve got to write the code yourself.

Sounds like booleans would get the job done in your case. Pseudocode example:

if (!nonInteractiveMode mouseOver buttonPressed) nonInteractiveMode = true;

You could use functions or coroutines for more complex checking.