Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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
0
Question by Teddy_p · Sep 06, 2014 at 12:26 AM · editoreventstandalonedisappeartab

Event.current.Use makes GUI disapear ONLY in standalone

Ok, so I have been spending my entire day trying to figure a work around this unity bug, and I am starting to get to the end of my rope. I can guarantee you it is a bug because in the unity editor it works fine, but in the standalone it doesn't.

Main problem is that the tab key does horrible things to the GUI (such as trying to change GUI focus to a text field) even if you don't want it to. So I have looked at umpteen threads that suggest how to solve this problem.

Some suggest use:

 if (Event.current.keyCode == KeyCode.Tab || Event.current.character== '\t') 
    Event.current.Use()

... well the problem with that is it makes my entire GUI disappear until another input is detected (when built only). Putting it at the end of the OnGUI() stops that single script's OnGUI() from disappearing but all other script's OnGUI() still disappear. I was able to have some luck in a separate project where if I change the execution order of the script that has the above code to first, then none of the GUI disappeared. But if I do the same in my main project, I still get disappearing GUI elements. Unlucky?

There is obviously a critical Unity problem here because in the editor its fine but in the standalone its not, so that's a big enough issue, so I have been trying for quite some time to figure out a work around but only to some avail.

I totally need to step away for a bit because, damn... but I would even be willing to pay someone to figure this out...Why cant unity just make it so that tab doesn't automatically try to swap between windows, and if you want to enable it you can. Don't force features on us, especially when they break other systems?

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

2 Replies

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

Answer by Teddy_p · Sep 06, 2014 at 08:37 AM

Ok so BoredMormon definitely led me in the right direction.

what ended up working was

  if (Event.current.type == EventType.keyDown && (Event.current.keyCode == KeyCode.Tab || Event.current.character == '\t'))
         {
             Event.current.Use();
         }

Thanks! ... still would sorta hope unity guys fix the difference between the standalone and editor when using Event.current.Use() though :)

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
1

Answer by Kiwasi · Sep 06, 2014 at 01:01 AM

I'm no expert on the GUI system, but I have a hunch that your layout event is being used. So everything that comes after does not get processed.

I suggest checking the event type. Add a condition to your if that checks that the event type is not a layout event. Can't tell you exactly how to code this, but you should be able to get through the docs from here.

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 Teddy_p · Sep 06, 2014 at 01:30 AM 0
Share

I changed it to

 if (Event.current.type != EventType.Layout && (Event.current.keyCode == $$anonymous$$eyCode.Tab || Event.current.character== '\t')) 
    Event.current.Use()

but still have issues.

avatar image philipstraw Teddy_p · Apr 16, 2020 at 09:13 AM 0
Share

I had the same issue and checking the event type solved it.

avatar image Kiwasi · Sep 06, 2014 at 01:48 AM 0
Share

Am I reading the docs wrong or should it be EventType.Layout ins$$anonymous$$d?

Also might want to consider brackets to logically arrange your && and || 's

avatar image Teddy_p · Sep 06, 2014 at 07:39 AM 0
Share

yes I edited the previous to reflect exactly what I had in the code... obviously it wouldn't have been able to compile if I used a lowercase.... The point still stands that the editor and game have different results.

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

24 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

Related Questions

Standalone build doesn't create gameobjects properly 1 Answer

Adjust the width of Animator tab's left panel 0 Answers

Works in the editor, but not when I publish it.. what's wrong..? 0 Answers

How do you access the editor event args? 1 Answer

Different behavior between editor and standalone changing time step 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