Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question How to use TMP_InputField.asteriskChar?

Discussion in 'UGUI & TextMesh Pro' started by newerish, Dec 27, 2023.

  1. newerish

    newerish

    Joined:
    Sep 13, 2019
    Posts:
    25
    Hi,

    I've created a TMP_InputField from script for a password input. But, it doesn't do anything and I still can see all characters. What should I do?
    Of course, I can manually replace last typed character(s) with asterisk(s) and store the original text somewhere, but what's the point of having an asteriskChar property? Or am I using it wrong?
    Code (CSharp):
    1.  public TMP_InputField AddInputField(GameObject baseInputField)
    2.         {
    3.             GameObject go = GameObject.Instantiate(baseInputField);
    4.             TMP_InputField field = go.GetComponent<TMPro.TMP_InputField>();
    5.             field.richText = false;
    6.             field.onFocusSelectAll = false;
    7.             field.asteriskChar = '*';
    8.             return fields;
    9.         }