Password InputField Censored (****) - Logging and Registration
Asked Answered
N

4

7

I am planning to do logging and registration. But I have a problem. I can't make the password InputField became like ***** (censored).

And maybe it wouldn't affect your answers but my game will be on the android platform.

Here is the sample image

Thank you.

Nodose answered 24/6, 2015 at 6:5 Comment(3)
How you have declared password field? And does show text in password enabled on phone?Livia
#6095462Apuleius
I use UI. I havent seen password field setting for UI. And show text is enabled. but I dont wanna hide text. I just want to add * when he wrote one character. E.g. when the player click on 'h' it should write '', than 'i' to ''. But not when he done writing like 'hi' to '**'Nodose
S
25

now you have a property in unity than you can change directly change . you select content type in Input field text and your value is changeenter image description here

Schaub answered 22/12, 2017 at 6:24 Comment(0)
D
2

Just use a EditText and set its inputType="textPassword

Herr is also an example to do so: http://www.mkyong.com/android/android-password-field-example/

Danettedaney answered 24/6, 2015 at 6:9 Comment(0)
W
0

Try something like

public string thePassword = "12345";
void OnGUI()
{
    passwordToEdit = GUI.PasswordField(new Rect(10, 10, 200, 20), 
                                       passwordToEdit, "*"[0], 25);
}

PasswordField Parameter List

  1. Where you would like the box.
  2. Your password to mask.
  3. The character to mask the password characters with.
  4. (Optional) Max masking length.
  5. (Optional) The textfield style.

Source: Unity Scripting API

Whodunit answered 24/6, 2015 at 6:31 Comment(0)
S
0

What about using InputField of the new UI ? You can set the content to Password:

Doc:

http://docs.unity3d.com/es/current/Manual/script-InputField.html

Sarmentum answered 2/7, 2015 at 20:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.