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.
  2. Dismiss Notice

Cannot switch to actions 'UI'; input is not enabled

Discussion in 'Input System' started by cubsyman234, Feb 6, 2021.

  1. cubsyman234

    cubsyman234

    Joined:
    Jun 13, 2018
    Posts:
    1
    Hi All

    I have an issue with switching actions in the new inout system. Currently I want to switch between "Player" and "UI" when the game is paused/unpaused and it seems to be doing that fine, the issue is this error being logged out "Cannot switch to actions 'UI'; input is not enabled"
    I'm certain I have to have just missed something supremely obvious, I just can't see it for the life of me. Thanks in advance!

    Using Unity 2019.4.18f1 and Input System 1.0.2
     
  2. Shinobi1507

    Shinobi1507

    Joined:
    Sep 8, 2010
    Posts:
    220
    This is the first result on google so I'm going to go ahead and bump this.
     
  3. Kfollen

    Kfollen

    Joined:
    Nov 12, 2019
    Posts:
    36
    Yeah, I'm working through this right now while trying to have my object keep its event references (using Unity Events) upon instantiation.
     
  4. Kfollen

    Kfollen

    Joined:
    Nov 12, 2019
    Posts:
    36
    Quick update: In my case I had set:
    Code (CSharp):
    1. [SerializeField] private PlayerInput playerInput;
    In a different class that then called:
    Code (CSharp):
    1. playerInput.SwitchCurrentActionMap("ShopControls");
    When I destroyed the object (the player) upon instantiating him again, that slot playerInput field was null. So I just threw a quick check into the method:

    Code (CSharp):
    1.             if (playerInput == null)
    2.             {
    3.                 GameObject player = GameObject.FindWithTag("Player");
    4.                 playerInput = player.GetComponent<PlayerInput>();
    5.             }
     
  5. Shinobi1507

    Shinobi1507

    Joined:
    Sep 8, 2010
    Posts:
    220
    That's what I've currently got too. I basically just hacked together a really awful global keeper of the Inputs for the 4 players to keep it going for now. I hope there is a better way than this.