Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
0
Question by darkhog · Aug 03, 2015 at 03:09 PM · uiinputkeyboardinputfield

New gui: How to disable keyboard input when user is typing?

How can I disable unrelated keyboard input when user is typing in an InputField?

Comment
Add comment · Show 3
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 XeliusFive · Aug 03, 2015 at 03:17 PM 0
Share

I'd like to know that one too!

avatar image Hellium · Aug 14, 2015 at 08:24 PM 0
Share

What do you mean by "unrelated keyboard input" ? Like arrow keys ?

You could make a global GameController using the Singleton design pattern to access it from anywhere. In this object, define a boolean saying if the user is typing. Every object that would normally react to the keyboard input would check if the variable is set to true or not.

avatar image darkhog · Aug 14, 2015 at 08:34 PM 0
Share

That's overly complex for just making character not move with WASD when he's typying in chat or something now is it? I need simple, easy to apply solution. Also I would have to scrap half of my code.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by darkhog · Aug 15, 2015 at 05:59 PM

Okay, answering myself. Kinda hackish, but it works:

     void Update () {
         //switching between mouse modes
         if ((Input.GetButtonUp("M"))){
             GameObject go = EventSystem.current.currentSelectedGameObject;
             InputField inputField = null; //creating dummy, null, InputField component
             if (go!= null) {
                 inputField = go.GetComponent<InputField>(); //trying to get inputField component
             }
             //if inputField still equals null, it means user isn't in edit field
             if (inputField==null) {Globals.lockmouse = !Globals.lockmouse;}
         }
     }

I'll try to refactor it later.

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
-2

Answer by whaleinthesea · Aug 14, 2015 at 08:44 PM

With getnameoffocusedcontrol you can easily fix this. Add this script to your moving object:

 if(GUI.GetNameOfFocusedControl() != "NameOfInputField"){
   //your code to move the object
 }

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 Hellium · Aug 15, 2015 at 07:44 AM 0
Share

Darkhog is using the new GUI, not the legacy system. And this solution is pretty like the one I proposed, which doesn't fit his needs.

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

26 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

Related Questions

Hover Over Input Field Before Inputting? 2 Answers

Can I disable the use of Input.GetKey(KeyCode("any key")) while an InputField is in use? 2 Answers

Android Keyboard Stuck / Won't Hide? 1 Answer

Inputmode on 18:9 mobile device shows navigation bar 0 Answers

Holotoolkit on screen keyboard won't open,Hololens on-screen keyboard won't open 1 Answer


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