passwordField

不想你离开。 提交于 2020-03-07 11:51:50
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输出密码
    }
    
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!