Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Okay to have multiple of the same InputAction?

Discussion in 'Input System' started by sarynth, Sep 28, 2020.

  1. sarynth

    sarynth

    Joined:
    May 16, 2017
    Posts:
    98
    Is it okay to instantiate multiple InputAction/PlayerControls?

    I'd like to use a single Input Action Map, but I want the handling to live in multiple files.

    For example, mouse clicks and drags live in a system tied to camera. But, then some buttons presses live with the Canvas.

    Will it be horribly inefficient to have one instance on each of the monobehaviors that handle the activity?
     
  2. Foxaphantsum

    Foxaphantsum

    Joined:
    Jul 5, 2013
    Posts:
    140
    Curious about this too.
     
  3. sarynth

    sarynth

    Joined:
    May 16, 2017
    Posts:
    98
    @Rene-Damm could you weigh in on this?

    I have three instances of my InputActions. One on my camera to listen to the mouse zoom, one on my canvas to listen to the escape key (and other similar items) to trigger the menu opening, and the main one on my character to listen for clicks and keyboard input.

    I see that when I add a debug output to InputSystem.onActionChange that it is triggering three times (well nine times, but three times on started, three times on performed, and three times on cancelled) since I have three enabled copies of my InputActionAsset. Is that going to cause problems?

    Should I create one master input handler and hook my canvas, character and camera to that master input handler class instead?

    Thanks.
     
    umbrella-crash likes this.
  4. sarynth

    sarynth

    Joined:
    May 16, 2017
    Posts:
    98
    @Rene-Damm (or anyone else.) Checking in again.