Search Unity

How to use for tools dev (Asset Store plugins)

Discussion in 'Input System' started by bourriquet, May 8, 2020.

  1. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    I'm trying to figure out how to make generic tools, like plugins or just company shared utils, compatible with the new Input System.
    How can we let the end user choose which InputAction to use for an action?
    The only way I see is:
    Code (CSharp):
    1. [SerializeField] InputActionAsset actionAsset;
    2. [SerializeField] string actionMapName;
    3. [SerializeField] string actionName;
    4.  
    5. void Awake()
    6. {
    7.     actionAsset.FindActionMap(actionMapName).FindAction(actionName).performed += PerformAction;
    8. }
    Is there a better way?
     
  2. Ramobo

    Ramobo

    Joined:
    Dec 26, 2018
    Posts:
    212
    There's the
    InputActionReference
    class. You can select the action you want in the inspector.
     
    bourriquet likes this.
  3. bourriquet

    bourriquet

    Joined:
    Jul 17, 2012
    Posts:
    181
    How did I miss that? Thanks!