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 diggerjohn · Apr 08, 2014 at 04:42 PM · guiinputbuildtextfield

How to slow down GUI

I have a date of birth textField that is working beautifully until I build it. When built the input is super sensitive. I select the field, hit a number key and WHAM ... that number takes the next 3 places in the date string before it stops entering and politely waits for another number. On entering another number WHAM .. another three entries of that number. Obviously I am not going to ever get a valid date this way.

Any suggestions as to why this is? And more importantly how to get it under control? This works exactly as expected in the editor. It only gets crazy on build. Arrrrghhhhhhh .....

Comment
Add comment · Show 4
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 diggerjohn · Apr 08, 2014 at 06:14 PM 0
Share

I put in a 5000 increment loop to print something. That slowed it down but just limited the display to taking up one extra character. Better but not a solution.

avatar image perchik · Apr 08, 2014 at 06:21 PM 0
Share

Please post your code as to how you're taking input and what you're doing with it.

avatar image fendorio · Apr 08, 2014 at 06:49 PM 0
Share

$$anonymous$$y guess is 'it's' listening out for a keydown event, not a keydown event followed by a keyup event.

avatar image diggerjohn · Apr 08, 2014 at 07:33 PM 0
Share

Thanks for looking at this ... I am going nuts .... I have taken out all the prints and commented stuff to try to clear it out, hope it is legible.

dosString = GUI.TextField (new Rect(25, 115, 100, 24), dosString, 10, textFieldStyle); // $$anonymous$$$$anonymous$$/dd/yyyy

chr = Event.current.character;

// Establish control of cursor with the following line TextEditor editor = (TextEditor)GUIUtility.GetStateObject(typeof(TextEditor), GUIUtility.keyboardControl);

if(chr == '0' || chr == '1' || chr == '2' || chr == '3' || chr == '4' || chr == '5' || chr == '6' || chr == '7' || chr == '8' || chr == '9'){

 if (charCount>9) charCount = 0;  // reset count increment to zero
 if(charCount == 2 || charCount == 5){        // force set of the slash between $$anonymous$$,d,y
     dosStringArray[charCount] = "/";
     charCount++;
 }
 dosStringArray[charCount] = chr.ToString();
 charCount++;
 editor.selectPos = charCount-1;    // set the cursor position
 editor.pos = charCount-1;    // set the cursor position        
 chr = 'k';  // trying to prevent focus from dropping back in the num test above

}

else{ dosString = ""; for(int x=0; x

chr = 'k'; // trying to prevent focus from dropping back in the num test above

Event.current.character = 'k'; // SET THIS TO PREVENT FOCUS DROPPING THROUGH NU$$anonymous$$BER TEST ABOVE

2 Replies

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

Answer by diggerjohn · Apr 13, 2014 at 11:00 PM

The solution was

if(Event.current.type.ToString() == "used")

This only passes once per event. This is the best way I found to stop the focus from rolling through the standard OnGUI 2 cycles per frame.

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 ivomarel · Apr 08, 2014 at 06:55 PM

You should use Input.GetKeyDown instead of Input.GetKey .

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 diggerjohn · Apr 08, 2014 at 08:10 PM 0
Share

I have tried ...

 if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Alpha1)|| Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space)){
                 gottaNumberDOS = true;
                 print ("gottaNumberDOS = " + gottaNumberDOS);
             }

As a test within OnGUI but it does not seem to be seen by GUI. It compiles alright but I get no response from Input.Get$$anonymous$$eyDown

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

Get key state while textfield has focus? 0 Answers

Input not registering while TextField is selected 3 Answers

TextField, Event.current, Input.GetKey, and GUI.FocusControl locking 1 Answer

Distribute terrain in zones 3 Answers

Backspace in limited length textfield causes ArgumentOutOfRangeException 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