JavaScript => public static function PasswordField(position: Rect, password: string, maskChar: char): string;
JavaScript => public static function PasswordField(position: Rect, password: string, maskChar: char, maxLength: int): string;
JavaScript => public static function PasswordField(position: Rect, password: string, maskChar: char, style: GUIStyle): string;
JavaScript => public static function PasswordField(position: Rect, password: string, maskChar: char, maxLength: int, style: GUIStyle): string;
C# => public static string PasswordField(Rect position, string password, char maskChar);
C# => public static string PasswordField(Rect position, string password, char maskChar, int maxLength);
C# => public static string PasswordField(Rect position, string password, char maskChar, GUIStyle style);
C# => public static string PasswordField(Rect position, string password, char maskChar, int maxLength, GUIStyle style);
Parameters 参数
position
Rectangle on the screen to use for the text field.
用于文本字段在屏幕上矩形的位置。
password
Password to edit. The return value of this function should be assigned back to the string as shown in the example.
编辑的密码,这个函数返回值应该赋回给字符串,看下面的例子。
maskChar
Character to mask the password with.
用于密码的字符遮罩。
maxLength
The maximum length of the string. If left out, the user can type for ever and ever.
控制字符串的最大长度,如果不设置用户可以一直输入。
style
The style to use. If left out, the textField style from the current GUISkin is used.
使用样式,如果不设置,密码字段的样式将应用当前的GUISkin皮肤。
Returns 返回
string The edited password.
返回被编辑的密码。
Description 描述
Make a text field where the user can enter a password.
创建文本字段,用户可以编辑密码。
JavaScript:
var passwordToEdit : String = "My Password";
function OnGUI () {
// Make a password field that modifies passwordToEdit.
passwordToEdit = GUI.PasswordField (Rect (10, 10, 200, 20), passwordToEdit, "*"[0], 25);
}
C#:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public string passwordToEdit = "My Password";
void OnGUI() {
passwordToEdit = GUI.PasswordField(new Rect(10, 10, 200, 20), passwordToEdit, "*"[0], 25);
}
}