unity3d常用控件

直接上代码,就能看懂了。

private string txt1;
private string pwd1;
private int tool1;
private bool isMuted;
private string msgBody;

// Use this for initialization
void Start () {
    txt1 = "";
    pwd1 = "";
    tool1 = 0;
    isMuted = true;
    msgBody = "";
}
//GUI内容显示
void OnGUI(){
    //文本框
    txt1=GUILayout.TextField (txt1,GUILayout.Width(100));
    //密码框,用*来代替原字符
    pwd1 = GUILayout.PasswordField (pwd1, '*', GUILayout.Width (100));
    //按钮,如果按下会返回true
    if (GUILayout.Button ("showLog")) {
        Debug.Log (1);
    }
    //Tab页,tool1用于接收按下的是哪一个tab,默认从0开始
    tool1 = GUILayout.Toolbar (tool1, new string[]{ "a", "b", "c" });
    Debug.Log (tool1);
    //复选框,可以选中或不选中
    if(GUILayout.Toggle(isMuted,"静音")){
        isMuted = false;
    }else{
        isMuted = true;
    }
    //多行文本
    msgBody=GUILayout.TextArea(msgBody,GUILayout.Width(100),GUILayout.Height(50));
}

 效果如下:

转载于:https://www.cnblogs.com/chenyangsocool/p/6946914.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值