public static string PasswordField (string password, char maskChar, params GUILayoutOption[] options);
public static string PasswordField (string password, char maskChar, int maxLength, params GUILayoutOption[] options);
public static string PasswordField (string password, char maskChar, GUIStyle style, params GUILayoutOption[] options);
public static string PasswordField (string password, char maskChar, int maxLength, GUIStyle style, params GUILayoutOption[] options);

参数

password要编辑的密码。应将该函数的返回值指定给该字符串,如示例中所示。
maskChar用于掩盖密码的字符。
maxLength字符串的最大长度。如果省略,用户可以键入任意长度的字符串。
style要使用的样式。如果省略,则使用当前 GUISkintextField 样式。

返回

string 编辑后的密码。

描述

创建一个可让用户输入密码的文本字段。

\ 游戏视图中的密码字段。

using UnityEngine;

public class ExampleScript : MonoBehaviour { string passwordToEdit = "My Password";

void OnGUI() { // Make a password field that modifies passwordToEdit. passwordToEdit = GUILayout.PasswordField(passwordToEdit, "*"[0], 25); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961