Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

[Solved] Using InputActionReference

Discussion in 'Input System' started by joshcamas, Oct 15, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,248
    Hello,

    I have a field on my monobehavior that is a InputActionReference.

    I'd like to hook a function to this input action, I've tried both of these options and neither of them seem to trigger:
    Code (CSharp):
    1. //Doesn't work
    2. interactAction.action.performed += OnInteractAction;
    3.  
    4. //Doesn't work either
    5. interactAction.ToInputAction().performed += OnInteractAction;
    Am I missing something? I figured using the reference is the best way to do it, since I've created it as an asset in a asset map, and I'd just like to reference that action asset.
     
  2. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Is the action getting enabled? After calling InputAction.Enable on the action, the above code is expected to work.
     
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,248
    Ah, that worked! Thank you :))
     
  4. LudiKha

    LudiKha

    Joined:
    Feb 15, 2014
    Posts:
    138
    @Rene-Damm Either of these still aren't working for me, even though I've enabled the InputAction. Any ideas?
     
  5. Rene-Damm

    Rene-Damm

    Unity Technologies

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    What's the debugger saying? (Window >> Analyze >> Input Debugger) It should show all the actions in play along with their bound controls.