Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Input Field Problem when set to Password

Discussion in 'UGUI & TextMesh Pro' started by freddyw9, Oct 28, 2014.

  1. freddyw9

    freddyw9

    Joined:
    Sep 19, 2012
    Posts:
    2
    I'm probably missing something really simple but I am unable to collect the text that is entered into a password field, I only get the *'s.

    My code looks like this:

    Code (CSharp):
    1. Text txtPass
    2. txtPass = rtPass.GetComponent<Text>();
    3. string strPass = txtPass.text;
    And when I enter the word password into the input field strPass contains "********" so how do I get out "password"?

    Thanks.
     
  2. dcarrigg

    dcarrigg

    Joined:
    May 21, 2014
    Posts:
    24
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    As a FYI this is changing for the next release as everyone seems to confuse text for what they need to use. The new names are .text (replaces .value) and .textComponent (replaces .text). This also make it more uniform to Text.text
     
  4. freddyw9

    freddyw9

    Joined:
    Sep 19, 2012
    Posts:
    2
    I got mixed up because I was using the Text item that was a child of the InputField instead of the InputField itself.

    This works:

    Code (CSharp):
    1.     InputField ifPass
    2.     ifPass = rtPass.GetComponent<InputField>();
    3.     string strPass = ifPass.value;
    4.  
     
  5. sridevi

    sridevi

    Joined:
    Sep 3, 2015
    Posts:
    3
    i have created inputField and script attached to this .i am getting the error "rtPass" doesn't exist in the current context