- Home /
Creating a Password Field
I have this:
Password = GUI.PasswordField(new Rect((Screen.width/2) - Screen.width * (0.01f/2.0f), (Screen.height/2) * (1.3f/1.5f),Screen.width * (0.3f/2.3f), Screen.height * (0.3f/10f)), Password, "*");
This is incorrect apparently, no idea why. Can someone help me? Thank you in advance! Here is the error I'm getting: "The best overloaded method match for `UnityEngine.GUI.PasswordField(UnityEngine.Rect, string, char)' has some invalid arguments"
Answer by TrickyHandz · Oct 06, 2013 at 02:01 PM
The problem is the char parameter at the end. Any char in code must be surrounded by single-quotes (apostrophe) rather than double-quotes. So it should look like this:
Password = GUI.PasswordField(new Rect((Screen.width/2) - Screen.width * (0.01f/2.0f), (Screen.height/2) * (1.3f/1.5f),Screen.width * (0.3f/2.3f), Screen.height * (0.3f/10f)), Password, '*');
Double-quotes create a string rather than a char, hence the error you received that there are invalid arguments.
Your answer
Follow this Question
Related Questions
How to make a login screen without input bar and without having to press enter on password field? 0 Answers
GUI.PasswordField "•" makes "?" 1 Answer
GUILayout.PasswordField() shows whole password when running on iOS before changing characters!?! 3 Answers
gui text and password field 1 Answer
C# GUI keypad 2 Answers