Search Unity

Password InputField value

Discussion in 'UGUI & TextMesh Pro' started by Ciryus, Aug 26, 2014.

  1. Ciryus

    Ciryus

    Joined:
    Sep 17, 2012
    Posts:
    38
    Hi,
    If I type a password with an inputfield of type password then try to get it by code using myField.text.text it returns me what is shown on the UI, namely asterisks.
    Is there a way to get the text behind the asterisks or is it delivered on next Release?
    Thanks.
     
    berg44 likes this.
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    you dont want to look at the text.text value when using a input field. This is because the input field just overrides that value with what should be shown (in your case the asterisks). To get the written value of the input field look at myField.value.
     
  3. FirebladeBR

    FirebladeBR

    Joined:
    Apr 21, 2014
    Posts:
    65
    Just solved it. I had to use value instead of text.
     
  4. celestius

    celestius

    Joined:
    Nov 17, 2014
    Posts:
    1
    Hello,

    I have the same problem but I can't find the value method.
    my code :

    public GameObject username;
    public GameObject password;
    public UnityEngine.UI.Text username_text
    public UnityEngine.UI.Text password_text

    public void login()
    {
    username_text = username.GetComponent<Text>();
    password_text = password.GetComponent<Text>();

    Debug.Log("the password is : " + password_text.text);
    }

    The Value method is for my GameObject or for my component ?

    Regards,

    Kévin
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    the .value was renamed to .text and .text to .textComponent. you need to use .text now.
     
    kisscsabi11 and frickshow like this.
  6. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    .text does not work for me. I only get asterisks

    Edit: I've got it. Have to use InputField.text not Text.text
     
    Last edited: Nov 30, 2014
    berg44 likes this.
  7. Sushma_Shetty

    Sushma_Shetty

    Joined:
    May 21, 2015
    Posts:
    1
    Please show the exact code usage which worked for you. I am also stuck similarly
     
  8. theSoenke

    theSoenke

    Joined:
    Dec 4, 2012
    Posts:
    106
    You simply need a reference to your InputField and then you can access the input by calling .text on it
     
  9. STBarnard

    STBarnard

    Joined:
    Jan 19, 2015
    Posts:
    3
    With a reference to the inputField, myField.text still returns asterisks.
     
  10. STBarnard

    STBarnard

    Joined:
    Jan 19, 2015
    Posts:
    3
    Ahh, I see.

    You need to have a InputField Variable and not a Text Variable.
    IE:

    InputField myField.text

    Not :

    Text myField.text
     
    GoldenSharkStudio likes this.
  11. seyacat

    seyacat

    Joined:
    Sep 10, 2015
    Posts:
    23
    Thanks
    string password = GameObject.Find ("input_register_password").GetComponent<InputField>().text;
     
  12. WackyDucky12

    WackyDucky12

    Joined:
    Apr 29, 2020
    Posts:
    1