- Home /
[4.6] Input field password string value is ************
I have an input field whose content type is password. When I try to get the string from input field all it's giving me is a line of asterix'
string _password = inputPassword.GetComponent<InputField>().text;
_password is "*"
What am I doing wrong here?
I'm guessing here, but if its type is password then I'm guessing that for security reasons the string is replaced with X's and the real password data is somewhere else.
yeah seems to be, but I dont know where to get the actual password..
Answer by gheeler · Nov 20, 2014 at 01:14 PM
Found out what was going wrong. I had a public RectTransform which in the editor I assigned the child 'Text', not the actual input field because in previous betas there was no direct access to the .text property.
I changed it to the actual InputField object and accessing it through there works properly
Hey, I am using 3d text for password using onscreen keyboard for my Android phone... I want my password to be in * type... Can you please help me :)?
Thanks in advance :)
Answer by troien · Nov 20, 2014 at 01:23 PM
When I try this, I get the password instead of a lot of asterix. Are you sure you are not overwriting it somewhere?
To test this I have a empty Scene with a Canvas and A child. This child has a RectTransform, Canvas Renderer, Text and a InputField component.
Then I also added the following script:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Test : MonoBehaviour
{
void Update()
{
Debug.Log(GetComponent<InputField>().text + " : " + GetComponent<Text>().text);
}
}
The result in the console then looks like this:
YourPassword : ************
(Unity 4.6.0f2)
Your answer
![](https://koobas.hobune.stream/wayback/20220613172012im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
4.6 Gui anchoring a ui element to a Game Object 2 Answers
Prefab as a Sprite 0 Answers
v4.6 UI Element's Positioning Incorrect 1 Answer
Unity GUI 4.6 stops animation 0 Answers