Version: 2022.1

EditorGUI.PasswordField

切换到手册
public static string PasswordField (Rect position, string password, GUIStyle style= EditorStyles.textField);
public static string PasswordField (Rect position, string label, string password, GUIStyle style= EditorStyles.textField);
public static string PasswordField (Rect position, GUIContent label, string password, GUIStyle style= EditorStyles.textField);

参数

position 屏幕上用于密码字段的矩形。
label (可选)显示在密码字段前的标签。
password 要编辑的密码。
style 可选 GUIStyle

返回

string 用户输入的密码。

描述

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

此方法的运行方式与 GUI.PasswordField 类似,但能够正确响应编辑器中的 Select All 等操作, 并可在前面提供一个可选标签。


编辑器窗口中的 Password 字段。

using UnityEngine;
using UnityEditor;

// Editor Script that creates a password field and lets you visualize what have you // typed in a label.

class EditorGUIPasswordField : EditorWindow { string text = "Some text here";

[MenuItem("Examples/Editor Password field usage")] static void Init() { EditorWindow window = GetWindow<EditorGUIPasswordField>(); window.Show(); }

void OnGUI() { text = EditorGUI.PasswordField( new Rect(3, 3, position.width - 6, 20), "Type Something:", text);

EditorGUI.LabelField( new Rect(3, 25, position.width - 5, 20), "Written Text:", text); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961