zoukankan      html  css  js  c++  java
  • GUI使用1——基础函数使用

    1 GUI.Window 窗口


    static function Window (id : int, clientRect : Rect, func : WindowFunction, text : String, style : GUIStyle) : Rect

    windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window");
    (注意,窗体创建完后要记得再赋值给该窗体)
    GUI.DragWindow(new Rect(0, 0, 10000, 10000));


    2 Mathf.Clamp 限制

    static function Clamp (value : float, min : float, max : float) : float

    限制value的值在min和max之间, 如果value小于min,返回min。 如果value大于max,返回max,否则返回value

    3 GUI.DragWindow();//GUI.DragWindow()函数必须写在其他代码的后头,否则会出现惊悚的事情


    4 GUI.Toolbar 工具栏

    public int toolbarInt = 0;//被选择按钮的索引号。
    public string[] toolbarStrings = new string[] {"Toolbar1", "Toolbar2", "Toolbar3"};
    void OnGUI() {
    toolbarInt = GUI.Toolbar(new Rect(25, 25, 250, 30), toolbarInt, toolbarStrings);
    }

    5 GUI.Box绘制纹理

    GUI.Box(Rect(0,0,Screen.width,Screen.height),"This is a title");

    6 设置GUI图片,选中图片
    6.1 texture中设置为GUI
    6.2 max size根据图片的尺寸设置
    6.3 format设置为Truecolor


    7 GUI.BeginScrollView 开始滚动视图
    返回Vector2类型,被修改的滚动位置scrollPosition。返回值应回传给你的变量,看下面的例子。
    //我们创建一个100,100的滚动视图,滚动内容为220,200,就是我们要查看的内容比滚动视图大
    scrollPosition = GUI.BeginScrollView (Rect (10,300,100,100),scrollPosition, Rect (0, 0, 220, 200));


    自定义皮肤使用步骤
    1 资源窗口中Create——》GUI Skin——》Custom style,设置先关属性(注意在border属性的设置)
    2 在OnGUI中GUI.skin = customSkin;(给皮肤赋值,否则会是默认的皮肤)
    3 在创建窗口时使用GUI.skin.GetStyle("windowRectB")
    eg.
    windowRectB = GUI.Window(0, windowRectB, MyDoWindow, "", GUI.skin.GetStyle("windowRectB"));

  • 相关阅读:
    java split
    百度知道
    2014年10月27日
    2014年10月27日
    mybatis批量update,返回行数为-1
    mybatis批量插入:oracle和mysql的区别
    oracle数据库,mybatis批量insert,缺失values字段
    java后台接收json数据,报错com.alibaba.fastjson.JSONObject cannot be cast to xxx
    C++——运算符重载(上)
    C++——友元
  • 原文地址:https://www.cnblogs.com/lv-sally/p/4563772.html
Copyright © 2011-2022 走看看