Maybe I'm missing something here. Is the GUI.PasswordField supposed to ignore the password character you supply while the iOS keyboard is open? I'm not using calls to iPhoneKeyboard. This is when the user touches a passwordfield and the keyboard pops up for input. While the user is typing the text entered appears just above the keyboard in the keyboard supplied text box and it appears in the password field as clear text. Once the user is done typing and clicks "done" or the keyboards "enter" key, the keyboard slides away and the password field replaces the text with the proper password character. So am I missing a setting?
I'm having the exact same issue. I even posted about it here http://answers.unity3d.com/question...e-password-when-running-on-ios-before-changin and so far it seems no one has a fix. Guess I'm gonna have to come up with a work around. It's obviously not acceptable on iOS out of the box.
Hi, here is a workaround for the GUILayout.PasswordField bug. It solves the following problems: 1) Password appears as clear text on the screen on iOS (bug 441113 reported). 2) iOS shows some suggestions and autocorrects while typing the password (!) I've tried some workarounds (see http://answers.unity3d.com/questions/55448/guilayoutpasswordfield-shows-whole-password-when-r.html), but without any success: 1) Workaround solutions that put a Label on top of a PasswordField still autocorrect... 2) Workaround solutions that test TouchScreenKeyboard.visible to hide the password briefly display it when the virtual keyboard is sliding... So my solution (inspired from the first workaround) is to place an invisible button on top of a GUI.Label. The button will manually open a virtual keyboard with the right parameters. Then we fill the GUI.Label with *s. (This UnityScript code is for Unity 3.5, replace TouchScreenKeyboard by iPhoneKeyboard if you are using Unity 3.4) Code (csharp): private var password : String = ""; private var keyboard : TouchScreenKeyboard = null; private var oldColor : Color; private var oldBackgroundColor : Color; private var r : Rect; function OnGUI() { ... if (Application.platform == RuntimePlatform.IPhonePlayer) { // make the button invisible by setting contentColor and backgroundColor to (0,0,0,0) oldColor = GUI.contentColor; GUI.contentColor = new Color(0,0,0,0); oldBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = new Color(0,0,0,0); // here is the invisible button that opens a keyboard on ios if (GUILayout.Button("", GUILayout.Width(250))) { keyboard = TouchScreenKeyboard.Open(password, TouchScreenKeyboardType.Default, false, false, true); } // update password content if (keyboard) { password = keyboard.text; } // restore the GUI colors GUI.contentColor = oldColor; GUI.backgroundColor = oldBackgroundColor; // get Rect of last GUI (the button) r = GUILayoutUtility.GetLastRect(); // draw a Label with * instead of password GUI.Label(r, (new String("*"[0], password.Length))); } else { // use the classic password field when running in the editor or on another platform password = GUILayout.PasswordField(password, "*"[0], GUILayout.Width(250)); } } If you have more than one text or password field in your GUI, you will have to add a check in the code, else the keyboard.text content will be duplicated between the fields... Here is an example for a login/password GUI: Code (csharp): private var login : String = ""; private var password : String = ""; private var keyboard : TouchScreenKeyboard = null; private var oldColor : Color; private var oldBackgroundColor : Color; private var r : Rect; private var fieldSelected : int = -1; function OnGUI() { ... if (Application.platform == RuntimePlatform.IPhonePlayer) { // make the button invisible by setting contentColor and backgroundColor to (0,0,0,0) oldColor = GUI.contentColor; GUI.contentColor = new Color(0,0,0,0); oldBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = new Color(0,0,0,0); // here is the invisible button that opens a keyboard on ios if (GUILayout.Button("", GUILayout.Width(250))) { keyboard = TouchScreenKeyboard.Open(login, TouchScreenKeyboardType.Default, false, false, false); fieldSelected = 0; } // update login content if (keyboard (fieldSelected == 0)) { login = keyboard.text; } // restore the GUI colors GUI.contentColor = oldColor; GUI.backgroundColor = oldBackgroundColor; // get Rect of last GUI (the button) r = GUILayoutUtility.GetLastRect(); // draw a Label with the login GUI.Label(r, login); } else { // use the classic text field when running in the editor or on another platform login = GUILayout.TextField(login, GUILayout.Width(250)); } ... if (Application.platform == RuntimePlatform.IPhonePlayer) { // make the button invisible by setting contentColor and backgroundColor to (0,0,0,0) oldColor = GUI.contentColor; GUI.contentColor = new Color(0,0,0,0); oldBackgroundColor = GUI.backgroundColor; GUI.backgroundColor = new Color(0,0,0,0); // here is the invisible button that opens a keyboard on ios if (GUILayout.Button("", GUILayout.Width(250))) { keyboard = TouchScreenKeyboard.Open(password, TouchScreenKeyboardType.Default, false, false, true); fieldSelected = 1; } // update password content if (keyboard (fieldSelected == 1)) { password = keyboard.text; } // restore the GUI colors GUI.contentColor = oldColor; GUI.backgroundColor = oldBackgroundColor; // get Rect of last GUI (the button) r = GUILayoutUtility.GetLastRect(); // draw a Label with * instead of password GUI.Label(r, (new String("*"[0], password.Length))); } else { // use the classic password field when running in the editor or on another platform password = GUILayout.PasswordField(password, "*"[0], GUILayout.Width(250)); } }
Bonjour, thanks a million for that report bournifle, (PS thank God, you are only a short drive to margaux to calm your troubles ) also on the answers site, http://answers.unity3d.com/questions/438153/is-guipasswordfield-buggered-.html I will post more solution code which you never know may help someone. Very best