1 static functionPasswordField (position:Rect,password:String,maskChar:char):String
2
3 static functionPasswordField (position:Rect,password:String,maskChar:char,maxLength:int):String
4
5 static functionPasswordField (position:Rect,password:String,maskChar:char,style:GUIStyle):String
position:表示控件在屏幕上的位置以及大小
password:编辑的密码
maskChar:用于密码的字符遮罩,即在屏幕上用何种字符遮掩密码
public class demo : MonoBehaviour {
private string stringDemo=123456;
private void OnGUI()
{
//创建密码框,同时使用字符“*”来隐藏并限制了密码长度
stringDemo = GUI.PasswordField(new Rect(Screen.width / 8.5f,
Screen.height / 9.5f, Screen.height / 1.5f, Screen.height / 8), stringDemp, '*', 25);
}
}
public class demo : MonoBehaviour {
private string stringDemo="123456";
public GUIStyle guiStyle;
private void OnGUI()
{
//创建密码框,同时使用字符“*”来隐藏并限制了密码长度
stringDemo = GUI.PasswordField(new Rect(Screen.width / 8.5f,
Screen.height / 9.5f, Screen.height / 1.5f, Screen.height / 8), stringDemo,
'*', 25,guiStyle);
print(stringDemo);//在Console->ErrorPause输出密码
}
}