How do I disable player input action map and enable the UI action map?

I am using the player input component (Input-System 1.0.0) with the behavior set to invoke unity events set. I have a player input action map and a UI action map. When the player brings up any UI i want to disable the player action map and enable the UI action map. I don’t want the player to be able to move around wall using UI. I did this in the old input system but with the new input system and unity events I’m lost.

Can i do this if i am using the player input component with unity events? if so are there any good resources and or suggestions?

Thanks

Allright, since this is still the #1 link in google search for this I’ll add that the most likely way to run into this issue is trying to disable the action map from another script/object not realizing each instance has its own copy of the Input Actions. Hope this helps.

I figured it out.

I needed to add using UnityEngine.InputSystem; statement. Doing this gave me access to the player input current action map and i could then call .Disable().

If you set a public static Input Action variable in one script and have all others access only that one, then you can enable and disable it without issues.

I am a little new to the input system, so this may not be the best solution, but it has worked for me so far.

I think you can use PlayerInput.SwitchCurrentActionMap or switching to another action map, here’s the docs.

https://docs.unity3d.com/Packages/com.unity.inputsystem@1.3/api/UnityEngine.InputSystem.PlayerInput.html#UnityEngine_InputSystem_PlayerInput_SwitchCurrentActionMap_System_String_

Here are my comment and code for my comment (sorry for my misuse of the forum)

Yooo, I’m having issues with this too, I can’t get my action map to change … I have an action map for walking and one for skiing and I want to be able to open a menu and choose between skiing an walking. I have managed to do the menu and when I pressed the ski button I have my skis appearing , and when I press the walk button my skis disappear - so I now my button is executing the function (code below) but the line to disable the action maps are not taken in account. The script is attached to the Canvas where the menu is maybe that’s what is causing them problem?

public class VehiculeSelection : MonoBehaviour
{
    public PlayerInputActions playerControls;
    public GameObject skiON;
    public GameObject skiOFF;
    public GameObject vehiculeCanvas;

    private void Awake ()
    {
        playerControls = new PlayerInputActions();
    }

    public void GoSkiing()
    {
        // write some script to make the skis appear and the action map change to skiing
        playerControls.Skiing.Enable();
        playerControls.Walking.Disable();
        vehiculeCanvas.SetActive(false);
        skiON.SetActive(true);
        skiOFF.SetActive(false);
    }

    public void GoWalking()
    {
        // write some script to make the skis disappear and the action map change to walking
        playerControls.Skiing.Disable();
        playerControls.Walking.Enable();
        vehiculeCanvas.SetActive(false);
        skiON.SetActive(false);
        skiOFF.SetActive(true);
    }

}