Unity Cookbook
  • 2D
    • New Input System - 2D Move
    • Pixel Sprite Setup
    • Animations
    • Animator in Script
    • Tilemap
    • 2D Camera Follow Player
  • UI OnlyFans
    • 9-Splice Sprite
    • Interactible Game Objects
      • NPCs
      • Items
      • Interactible Marker
    • Dialogue System
      • Conversa Plugin
      • DiaManager.cs
      • DiaTrigger.cs
      • DiaManager.cs Alternate
      • Choices in Dialogue
    • New Input System - Interact
    • Designing the General Menu
    • New Input System - Open Menu
      • UI Buttons
      • GeneralMenu.cs
    • Controls Explanation UI
    • Items Menu
Powered by GitBook
On this page
  1. UI OnlyFans

New Input System - Open Menu

PreviousDesigning the General MenuNextUI Buttons

Last updated 1 year ago

How to use Input with on screen buttons.

Disabling Movement for UI

To switch to UI, you can change the Action Map. You need to set the default action map in the previous section first before switching.

using UnityEngine.InputSystem;

...

[SerializeField] private PlayerInput playerInput;

public void OnOpenMenu(InputAction.CallbackContext ctx)
    {
        Debug.Log("UI Should Open");
        playerInput.SwitchCurrentActionMap("UI");
    }

Alternately, You can switch the Action Map in the Inspector of the PlayerInputComponent.