Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by devinallen1 · Feb 11, 2020 at 04:31 AM · uiinputscript.controllerplayer movement

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

New input system 1.0.0 I am using the player input component 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 im 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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by devinallen1 · Feb 11, 2020 at 06:19 AM

I figured it out. I needed to be using UnityEngine.InputSystem as a using statment. Doing this gave me access to the player input current action map and i could then call .Disable()

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jamezilla0 · Feb 02, 2021 at 11:59 AM 0
Share

I tried this however it did not work... What exactly did you do? Can you share a code snippet?

avatar image Xelioth · Mar 17, 2021 at 10:56 PM 0
Share

So this is the top google result for how to disable input action maps, and you mention the solution, but don't have the syntax. I've searched everywhere for this dang syntax and everyone skips it as obvious... Any chance you could share it for us?

avatar image sololegends Xelioth · Apr 17, 2021 at 12:18 PM 0
Share

Encountering this myself just now and co$$anonymous$$g onto this answer first.. Here is the actual answer for those after me..

  1. Get the player input component
    PlayerInput input = GetComponent<PlayerInput>(); input.actions.Disable();

  2. Access the actions object and disabled/enable it
    input.actions.Disable();

All together:
GetComponent<PlayerInput>().actions.Disable();

avatar image alisaneei sololegends · Apr 18, 2021 at 04:09 PM 0
Share

I also have this problem. I'm trying to switch the action map from Player to UI whenever I press the pause button but it's not working. I don't know what the problem is. Should I use something else instead of actions? Any suggestions? This is my pause menu code:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.InputSystem;
 
 public class PauseMenu : MonoBehaviour
 {
     public static bool GameIsPaused = false;
     public GameObject pauseMenuUI;
 
     public void PauseInput(InputAction.CallbackContext context)
     {
         if (GameIsPaused)
         {
             Resume();
         }
         else
         {
             Pause();
         }
     } 
 
     public void Resume()
     {
         Player.Instance.GetComponent<PlayerInput>().actions.Enable();
         pauseMenuUI.SetActive(false);
         Time.timeScale = 1f;
         GameIsPaused = false;
     }
 
    public void Pause ()
     {
         Player.Instance.GetComponent<PlayerInput>().actions.Disable();
         pauseMenuUI.SetActive(true);
         Time.timeScale = 0f;
         GameIsPaused = true;
     }
 }


avatar image
3

Answer by Gawidev · May 22, 2021 at 11:09 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cassius · May 27, 2021 at 06:27 PM 0
Share

Thanks for this!

I have been banging my head against walls 8 hours trying to update my Input Actions on the fly through code. Seems, with what you've said, I've been looking in the wrong place to verify my changes all along. I must have missed this in the documentation somewhere. ;)

avatar image
0

Answer by Bmarlyman21 · Nov 10, 2021 at 01:45 PM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Saucyminator · May 29 at 06:37 PM

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

237 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I translate my arrow keys input to my controller joystick? 0 Answers

Hover Over Input Field Before Inputting? 2 Answers

How to change a float value with UI buttons,How Can I control a character with UI buttons? 1 Answer

Link UI Input Field to Script 2 Answers

Help Needed: How to Use Input Manager on UI Button 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges