Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 judy3turn · Feb 01, 2015 at 07:12 PM · inputfield

UI InputField does not consumer keyboard input

I have an input field which, when I type into it, also causes my character to move whenever I type in a movement key. For example, with each space in the input field, my avatar jumps.

I would think there would be a flag in the input field that says "consume these" and I'm hoping to find one because an update method that checks every tick and eats the character if the pointer is over the UI seems like a horrible waste of code and a huge hit in terms of unnecessary update cycles. Can't the UI do this for me? It should!!!

Is there something I don't know that will help with this or is the answer "suck it up and consume it yourself"?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by steakpinball · Feb 02, 2015 at 07:04 PM

EventSystems.BaseEventData.used is the closest thing to what you're looking for. For each event this starts as false. When it is consumed by the UI it is set to true. Getting a reference to the event object and checking it will still require an update loop. A simpler solution would be to maintain the focus of the cursor.

 void Update() {
   if (gameHasFocus) {
     // Process game world input
   }
 }

i.e. suck it up and consume it yourself

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 fullstack · Aug 06, 2015 at 02:50 PM 0
Share

I really didn't get " Getting a reference to the event object", how can I get reference on Event Object ? For example I have Camera$$anonymous$$ovement script which uses "space" as reset position, when I press space in Input Field my Camera$$anonymous$$ovement script is also resetting camera position, how can I get Event Object in Camera$$anonymous$$ovement script ?

         void Update() {
             if (Input.Get$$anonymous$$eyDown("space")) {
         //How Can I get Event Object here ?StartCoroutine(ResetPosition(resetSpeed));
                 return;
             }


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

20 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

Related Questions

UI 4.6 input field how do I use the .onendedit? 1 Answer

Max Level reached ever 1 Answer

How to limit the number of line in an imputField? 0 Answers

Catching get focused for UI InputField 0 Answers

Making an image appear from a different script 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