Search Unity

Question How do I assign an InputActionReference in code?

Discussion in 'Getting Started' started by tleylan, Nov 30, 2022.

  1. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    618
    I currently have an InputActionReference defined in my class.

    Code (CSharp):
    1.     private InputActionReference _uiToggle;
    2.  
    This can be set in the Inspector by dragging an XRI Default Input Actions "XRI LeftHand Interaction/Switch UI" from the Starter Assets folder. I would like to assign this value in code if possible. How do I obtain a reference?

     
  2. tleylan

    tleylan

    Joined:
    Jun 17, 2020
    Posts:
    618
    With help from this video:
    I was able to build the class and use it. Hooray.