- Home /
GUI.PasswordField getting erased after clicking on the PasswordField.
Hello everyone
I am facing a unique problem while using the following line of code.
data.password = GUI.PasswordField(Rect(screenWidth * 0.29, screenHeight * 0.58, screenWidth * 0.6, screenHeight * 0.05), data.password, "*"[0], 16);
This problem is specifically found in the iOS build of the project. First I tap on the Password text field, a key board appears where I type the password & the password appears in the password text field in the form of *(Asterik). When I am finished typing, instead of pressing the return key or Done key on the key board, I click the password text field again. Now, what was written previously in the Password field gets erased. But this doesn't happen when I click the done button or return key in the key board, & then touch the password field. I have no idea what's going on here.
It;s driving me crazy. I will appreciate any help regarding this. I am tesing on iPad iOS 7.1.1
why do you not want it to be erased to begin with? you wont be able to read what you wrote so theres no need to edit it aftwards anyway... if you for example want to login you enteder your username and your password than you click login and the login menu will dissapper if you want to change your password after you entered something in the password box you will most likely erase the whole stuff you wrote anyway because you can't be sure if its right so why not leave it as it is? ;)
But well you seem to really want to do that...
data.password = GUI.PasswordField(Rect(screenWidth * 0.29, screenHeight * 0.58, screenWidth * 0.6, screenHeight * 0.05), data.password, "*"[0], 16);
string temppassword = "";
if (data.password != "")
temppassword = data.password;
if(temppassword != "" && data.password =="")
data.password = temppassword;
i hope it helps ! :)
it will just store the password into a temp variable when its not empty and if the passwordfield gets empty itll be applied to the passwordfield BUT dont put the new variable in the update function like it is here ! put it at the top of your script !
Actually the page where I am entering the password is like a registration page. There are four textFields in it. After entering the password in the password field, when I touch the retype Password field, the password written in the password field gets erased.
This is what I don't to happen. Please help me.
This is a working structure:
using UnityEngine;
using System.Collections;
public class Join : $$anonymous$$onoBehaviour {
string userPassword = "";
string retypePassword = "";
void OnGUI() {
userPassword = GUI.PasswordField(new Rect(0,10,100,24), userPassword, "*"[0], 16);
retypePassword = GUI.PasswordField(new Rect(0,50,100,24), retypePassword, "*"[0], 16);
}
}
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Limit on GUI Components? 0 Answers
Unity editor works but the built game doesnt. 0 Answers
GUI Text as Button 1 Answer
HorizontalScrollbar not appearing in GUILayout.BeginScrollview C# 3 Answers