unity学习之GUI基础2

来源:互联网 发布:java正则表达式 . 编辑:程序博客网 时间:2024/05/16 14:10
 欢迎来到unity学习社区
      Label      (绘制文本和图片)

      Box         (绘制一个图形框)

      Button     (绘制按钮,响应单击事件)

      RepeatButton(绘制一个处理双击按下按钮的事件)

      TextField (绘制一个单行文本输入框)

      PasswordField (绘制一个密码输入框)

      TextArea  (绘制一个多行文本输入框)

      Label (绘制文本  不可点击  不可删除)

     GUI.Label(new Rect(20,20,20,20),"Hello World");
    
     public  Texture2D img;
    
      GUI.Label(new Rect(20,20,img.width,img.heiget),img);

      Box  (文本边框  不可点击 不可删除)

       GUI.Box(new Rect(20,20,20,20),"Hello Word");
     
       public Texture2D img;
      
       GUI.Box(new Rect(20,20,img.width,img.heght),img);

       Buttom(按键)(单击)

       public texture2D img 

       GUI. Button(new Rect(20,20,100,20),"Hello Word");

       GUI.Button(new rect(20,20,img.width,img.height),img);

       GUI.Button(new Rect(20,80,150,20),new GUIContent("我有提示",“恭喜你中奖了”));
 
       GUI.label(new rect(20,20,100,20),GUI.tooltip);

       RepeatButton(双击)

       public texture2D img 

       GUI. RepeatButton(new Rect(20,20,100,20),"Hello Word");
 
       GUI.RepeatButton(new rect(20,20,img.width,img.height),img);

       GUI.RepeatButton(new Rect(20,80,150,20),new GUIContent("我有提示",“恭喜你中奖了”));
   
       GUI.label(new rect(20,20,100,20),GUI.tooltip);
     
      TextField(输入框)
    
      string str="Hello  World";

      str=GUI.TextField(new rect(20,20,200,40),str,10);

       passwordField

       string str="";
     
       str=GUI.passwordField(new rect(10,20,200,20),str,"*",10);

       TextArea  (文本域)

       string str = "Hello Word";

      str=GUI.TextArea(new rect(20,20,200,100),str,100)

      Application.LoadLevel("Login");    //跳转到登陆页面

      Application.LoadLevel(Application.loadedLevelName);//重新跳转本页面

      Application.Quit();  //退出游戏   注:在游戏发布后可使用

      GUI.skin.label.fontSize=50;//设置字体大小 

      GUI.color = Color.red;//设置字体颜色

     游戏暂停和开始

      游戏暂停

      Time.timeScale=0;

      游戏开始

      Time.timeScale=1;

0 0