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.

Maifee Ul Asad
  • 3,992
  • 6
  • 38
  • 86
Atilla Gundogan
  • 101
  • 1
  • 1
  • 8
  • How you have declared password field? And does show text in password enabled on phone? – Amit Jun 24 '15 at 06:08
  • http://stackoverflow.com/questions/6094962/android-how-to-set-password-property-in-an-edit-text – Syed Nazar Muhammad Jun 24 '15 at 06:08
  • 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 '**' – Atilla Gundogan Jun 24 '15 at 15:57

4 Answers4

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

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/

Ingo Schwarz
  • 607
  • 5
  • 15
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

Nick Roberts
  • 245
  • 4
  • 12
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

mayo
  • 3,845
  • 1
  • 32
  • 42