passwordField

时间:2020-03-07
本文章向大家介绍passwordField,主要包括passwordField使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
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输出密码
    }
    
}

原文地址:https://www.cnblogs.com/zyz322/p/12433105.html