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
1
Question by franktinsley · Mar 30, 2011 at 07:43 PM · guiiossecuritypassword

GUILayout.PasswordField() shows whole password when running on iOS before changing characters!?!

When I test my game's twitter login view in the editor, the GUILayout.PasswordField() works as expected hiding every character immediately and revealing nothing. However when I run it on my iPhone 4 and it has to have the characters input from the iOS keyboard it behaves much differently. It actually shows the ENTIRE PASSWORD until the user hits the Done button confirming they are finished entering their password where it finally turns them all into the asterisk character I gave it. There's no way I can use it like this as it would potentially reveal many of my user's twitter passwords to onlookers. Any ideas on how to fix this would be INDESCRIBABLY HELPFUL! I'll add my OnGUI() implementation here.

static var twitterUser : String = ""; static var twitterPassword : String = "";

function OnGUI() { if (rootView.highRes) { GUI.skin = rootView.highResGUISkin; } else { GUI.skin = rootView.lowResGUISkin; } if (selected) // this turns true when the root view calls one of this view's EnterFrom functions { startPos = Mathf.Lerp(startPos, endPos, Time.deltaTime rootView.guiDamp); GUILayout.BeginArea(Rect(startPos, 0, Screen.width, Screen.height)); GUILayout.BeginVertical();// begin open centering junk GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace();// end open centering junk GUILayout.BeginVertical("box"); GUILayout.Box("TWITTER ACCOUNT"); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); GUILayout.Label("USERNAME", "twitterLabel"); GUILayout.Label("PASSWORD", "twitterLabel"); GUILayout.EndVertical(); GUILayout.BeginVertical(); twitterUser = GUILayout.TextField(twitterUser, 15); twitterPassword = GUILayout.PasswordField(twitterPassword, ""[0]); GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.FlexibleSpace();// begin close centering junk GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.EndVertical();// end close centering junk GUILayout.EndArea(); } }

Comment
Add comment · Show 2
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 franktinsley · Apr 06, 2011 at 02:33 PM 0
Share

Filed a bug report. Hopefully they can find a fix for me soon so I don't end up using a hack work around.

avatar image Graham-Dunnett ♦♦ · Jun 29, 2011 at 01:14 PM 0
Share

Bug is confirmed and with a developer for fixing. (June 29th 2011)

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Molix · Jun 29, 2011 at 06:05 PM

Until the bug is fixed, you may be able to get around it by making the text invisible by changing the transparency, and then drawing a series of "*" over top in the regular color of it equal to the length of the text. e.g. (untested, but should give the gist)

 public static string MyPasswordField( string password )
 {
   Color oldColor = GUI.contentColor;                  // save it
   GUI.contentColor = new Color( 0,0,0,0 );            // transparent (0 alpha)
   password = GUILayout.TextField( password );         // regular field, invis text
   GUI.contentColor = oldColor;                        // restore color
   Rect r = GUILayoutUtility.GetLastRect();            // wherever that was, find out
   GUI.Label( r, new string( '*', password.Length ) ); // draw * over top
   return password;
 }

If the GUI.contentColor doesn't work as expected you could just make a special "invisible text textfield" GUIStyle and pass that instead (same basic idea, just a different way).

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 DanjelRicci · Apr 23, 2013 at 10:12 PM 0
Share

Just tested, it works flawlessy. Thanks a lot, I really needed this!

But unfortunately, the original bug is still here...

avatar image
1

Answer by bournifle · Jan 27, 2012 at 04:59 PM

Almost a year has passed and this bug is still there...

The problem with the previous hack from Molix is that the virtual keyboard is still showing the password on my iPad...

To get around that, you may use the hack from Molix and hide the keyboard text field:

 TouchScreenKeyboard.hideInput=true;


Or you may hide the GUI text when typing the password on the virtual keyboard:

 var oldColor : Color = GUI.contentColor;
 if (TouchScreenKeyboard.visible) {
     GUI.contentColor = new Color(0,0,0,0);
 }
 password = GUILayout.PasswordField(password, "*"[0]);
 if (TouchScreenKeyboard.visible) {
     GUI.contentColor = oldColor;
 }

(This code is for Unity 3.5, replace TouchScreenKeyboard by iPhoneKeyboard if you are using Unity 3.4)

This last solution is not perfect since the password is still briefly displayed when the keyboard is sliding...

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 bournifle · Feb 10, 2012 at 11:44 AM

I've found a workaround for this bug, using an invisible button and the TouchScreenKeyboard.Open() function.

See my post (the 4th one) for an example here: http://forum.unity3d.com/threads/65337-GUI.PasswordField-issue

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Problem with centering text 1 Answer

iOS development and GUI for it 1 Answer

size of GUI pics too big 1 Answer

Issue with GUI.TextArea keyboard on iPhone 0 Answers

Detecting Input with GUI Textures? 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