码迷,mamicode.com
首页 > 编程语言 > 详细

unity传统GUI学习一.

时间:2018-03-31 14:18:29      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:pos   text   com   贴图   设置   滑动条   nta   绘制   too   

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class gui : MonoBehaviour {

    string editName;  
    string editPassword;  
    float toolBarValue0;  
    float toolBarValue1;  
    public Texture tex;  
    void Start()  
    {  
        editName = "请输入用户名";  
        editPassword = "请输入密码";  
        toolBarValue0 = 0;  
        toolBarValue1 = 0;  
    }  


    void OnGUI ()
    {  
        GUI.Label (new Rect (10, 10, 100, 30), "阿峰学习"); //将字符串显示在屏幕上  

        GUI.DrawTexture (new Rect (10, 50, 100, 80), tex);  //绘制贴图  

        //检测按钮  
        if (GUI.Button (new Rect (10, 200, 100, 30), "普通按钮")) {  
            Debug.Log ("按下了按钮。");  
        }  
        //检测连续按钮  
        if (GUI.RepeatButton (new Rect (10, 250, 100, 30), "连续按钮")) {  
            Debug.Log ("正在按按钮!");  
        }  

        //设置文本输入框  
        editName = GUI.TextField (new Rect (150, 40, 200, 30), editName, 15);  
        editPassword = GUI.PasswordField (new Rect (150, 80, 200, 30), editPassword, "*" [0], 15); 
//垂直和水平滑动条 toolBarValue0 = GUI.VerticalSlider (new Rect (200, 200, 30, 100), toolBarValue0, 100, 0); toolBarValue1 = GUI.HorizontalSlider (new Rect (200, 180, 100, 30), toolBarValue1, 0, 100); } }
技术分享图片

 

 

 

unity传统GUI学习一.

标签:pos   text   com   贴图   设置   滑动条   nta   绘制   too   

原文地址:https://www.cnblogs.com/fengdaren/p/8681770.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!