Search Unity

Resolved Binding OnScreenButton to InputAction

Discussion in 'Input System' started by EdoC-QWERTY, Mar 26, 2022.

  1. EdoC-QWERTY

    EdoC-QWERTY

    Joined:
    Feb 1, 2020
    Posts:
    75
    Hello,

    Is it possible to bind an On-Screen Button component to an Input Action instead of a button?

    So if the player binds the Action to another key it will still trigger it?


    Edit.

    I found a solution myself, I'm leaving it here in case anyone else is looking for it


    Code (CSharp):
    1.  
    2. OnScreenButton screnbutton;
    3. [SerializeField] InputActionAsset gamesinputsasset;
    4. [SerializeField] string inputstyring;
    5. private void Awake()
    6.      {
    7.    
    8.      
    9.   var dd = gamesinputsasset.FindAction(inputstyring);
    10.      
    11.         string controlpathstring = dd.bindings[0].path;
    12.  
    13.        screnbutton.controlPath = controlpathstring;
    14.      
    15.  
    16.      
    17.      }
     
    Last edited: Mar 26, 2022