Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

handeling inputs in Unity

Discussion in 'Scripting' started by Crocsx, Nov 26, 2015.

  1. Crocsx

    Crocsx

    Joined:
    Nov 6, 2014
    Posts:
    2
    Hi everyone,

    So I've searched for an hour now, a good way to handle inputs in Unity. What I would like to do is :

    - Create a class InputManager, that will handle all game input, InputMessage is the only class to access the original Unity Input, whenever a input occurs it.

    - Components can register to the input manager, telling the InputManager what input they want to listen and what function it should call. let's say for exemple onPress of "Fire1" InputManager will call myFunction1();


    Now my question is, how do I listen to all input in unity and get the actual used input. By that I mean, if i have 100 inputs, my InputManager would contain 100 if in the Update to check which of my inputs are used. I would like to have a thing that (like in javascript :3) contain all the input actually used so that in the update i just have to loop on the currents key used and my InputManager would only call the function.

    I hope i'm clear enough :3

    Is there a way to do that?