public static string PasswordField (string password, params GUILayoutOption[] options);
public static string PasswordField (string password, GUIStyle style, params GUILayoutOption[] options);
public static string PasswordField (string label, string password, params GUILayoutOption[] options);
public static string PasswordField (string label, string password, GUIStyle style, params GUILayoutOption[] options);
public static string PasswordField (GUIContent label, string password, params GUILayoutOption[] options);
public static string PasswordField (GUIContent label, string password, GUIStyle style, params GUILayoutOption[] options);

Parameters

label(可选)显示在密码字段前的标签。
password要编辑的密码。
style可选 GUIStyle
options一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

Returns

string 用户输入的密码。

Description

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

This works just like GUILayout.PasswordField, but correctly responds to select all, etc. in the editor, and it can have an optional label in front.


Simple window that visualizes what you have typed in the password field.

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

using UnityEditor; using UnityEngine;

public class ExampleClass : EditorWindow { string text = "Some text here";

[MenuItem("Examples/Editor Password field usage")] static void Init() { ExampleClass window = (ExampleClass)GetWindow(typeof(ExampleClass)); window.Show(); }

void OnGUI() { text = EditorGUILayout.PasswordField("Type Something:", text); EditorGUILayout.LabelField("Written Text:", text); } }