GUI布局类 GUILayout

GUILayout  类

   GUILayout是用于UnityGUI自动布局的类。 参见:GUI Layout tutoria

    类方法

    ◆ static function BeginArea(screenRect : Rect) : void
    ◆ static function BeginArea(screenRect : rect, text : string) : void
    ◆ static function BeginArea(screenRect : Rect, image : Texture) : void   
    ◆ static function BeginArea(screenRect : Rect, content : GUIContent) : void
    ◆ static function BeginArea(screenRect : Rect, style : GUIStyle) : void
    ◆ static function BeginArea(screenRect : Rect, text : string, style : GUIStyle) : void
    ◆ static function BeginArea(screenRect : Rect, image : Texture, style : GUIStyle) : void
    ◆ static function BeginArea(screenRect : Rect, content : GUIContent, style : GUIStyle) : void    //   描述:在屏幕的固定区域开始一个GUI空间的GUILayout块。

    默认的,任何使用GUILayout制作的GUI空间都放置在屏幕的左上角。如果你想在任一区域放置一系列自动布局的控件,使用GUILayout.BeginArea定义一个新的区域以便自动布局系统可以使用它。

    参数

     text可选的显示在该区域中的文本
     image  可选的显示在该区域中的纹理
     content  可选的在该区域顶部显示的文本,图片和提示
     style  使用的风格。如果留空,空的GUIStyle(GUIStyle.none)将被使用,给出一个透明的背景。参见:EndArea

    function OnGUI()
    {

     GUILayout.BeginArea(Rect(200, 200, 100, 100));
     GUILayout.Button(“Click me”);
     GUILayout.Button(“Or me”); 
    GUILayout.EndArea();
    }

    在混合GUILayout代码是这个函数是非常有用的。必须与EndArea调用匹配。BeginArea / EndArea不能嵌套。

    ◆ static function BeginHorizontal(params options : GUILayoutOption[]): void
    ◆ static function BeginHorizontal(style : GUIStyle, params options : GUILayoutOption[]): void   //  描述:开始一个水平控件组。
 
    所有在这个元素内部渲染的空间将被一个接一个的水平放置,改组必须调用EndHorizontal关闭。参见:GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight

     参数

     style这个风格用于背景图片和填充值。如果留空,背景是透明的。
     options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这个设置的值将覆盖由style定义的设置。
 
    ◆ static function BeginScrollView(scrollPosition : Vector2, params options : GUILayoutOption[]) : Vector2
    ◆ static function BeginScrollView(scrollPosition : Vector2, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle, params options : GUILayoutOption[]) : Vector2
    ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, params options : GUILayoutOption[]) : Vector2
    ◆ static function BeginScrollView(scrollPosition : Vector2, style : GUIStyle) : Vector2
    ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle,  params options : GUILayoutOption[]) : Vector2
    ◆ static function BeginScrollView(scrollPosition : Vector2, alwaysShowHorizontal : bool, alwaysShowVertical : bool, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle,  background : GUIStyle, params options : GUILayoutOption[]) : Vector2  //   描述:开始一个自动布局滚动视。

    参数:

    scrollPostion 用来显示的位置
    alwaysShowHorizontal  可选的参数用来总是显示水平滚动条。如果为假或者留空,它将只在ScrollView中的内容比滚动视宽时显示。
    alwaysShowVertical 可选的参数用来总是显示垂直滚动条。如果为假或者留空,它将只在ScrollView中的内容比滚动视高时显示。  
    horizontalScrollbar 用于水平滚动条的可选GUIStyle。如果不设置,将使用当前GUISkin的horizontalScrollbar。
    verticalScrollbar 用于垂直滚动条的可选GUIStyle。如果不设置,将使用当前GUISken的verticalScrollbar风格。

    返回Vector2 – 修改过的scrollPosition。回传这个变量,如下的例子:自动布局滚动视,将使用任何你放置在它们中的内容并正常显示出来。如果他不适合,将显示滚动条,BeginScrollView的调用总是与EndScrollView的调用匹配。

    var scrollPosition : Vector2;  //   这个变量对于空间来说就是这个滚动视查看子元素的位置。

    var longString = “This is a long-ish string”;    //   显示在滚动视中的字符串,下面两个按钮添加,清除这个字符串。

    function OnGUI()
    {


 scrollPosition = GUILayout.BeginScrollView(scrollPosition,  GUILayout.Width(100),  GUILayout.Height(100));  //开始一个滚动视,所有矩形被自动计算。它将使用任何可用的空间并确保内容排列正确 ,这是小的最后两参数来强制滚动条出现


    GUILayout.Height(longString); 

    if(GUILayout.Button(“Clear”)   //  添加一个简单的标签到滚动视内部。注意滚动条如何与文字换行正确的工作。

    longString = “”; //结束我们上面开始的滚动条

   GUILayout.EndScrollView();    //添加一个按钮来消除字符串。这个是在滚动区域内部,因此它也将被滚动。注意按钮如何变窄为垂直滚动条留出空间

   if(GUILayout.Button(“Add MoreText”))    //现在我们在滚动视外边添加一个按钮 – 这将显示在滚动区域的下边
   {
     longString += “nHere is another line.”;
    }

    ◆ static function Box(params option : GUILayoutOption[]) : void
    ◆ static function Box(style : GUIStyle, params option : GUILayoutOption[]) : void    //  描述:开始一个垂直控件组。所有在这个元素内部渲染的空间将被一个接一个地垂直放置。改组必须调用EndVertical关闭。

    参数

    style 这个风格将用于背景图片和填充值,如果留空,背景是透明的。
    options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

     参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Box(image : Texture, params option : GUILayoutOption[]) : void
    ◆ static function Box(text : string, params option : GUILayoutOption[]) : void
    ◆ static function Box(contend : GUIContent, params option : GUILayoutOption[]) : void
    ◆ static function Box(image : Texture, style : GUIStyle, params option : GUILayoutOption[]) : void
    ◆ static function Box(text : string, style : GUIStyle, params option : GUILayoutOption[]) : void
    ◆ static function Box(contend : GUIContent, style : GUIStyle, params option : GUILayoutOption[]) : void  //  描述:制作一个自动布局box,这将制作一个实心box,如果你想制作一个包含一些内容的box,使用一个子组函数的

    参数

    text 显示在该box上的文本
    image显示在该box上的Texture
    content用于这个box的文本,图形和提示
    style 使用的风格。如果不设置,将使用当前的GUISkin的box风格。
    options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    风格参数(BeginHorizontal, BeginVertical, 等等) 参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Button(image : Texture, params options : GUILayoutOption[]) : bool
    ◆ static function Button(text : string, params options : GUILayoutOption[]) : bool
    ◆ static function Button(content : GUIContent, params options : GUILayoutOption[]) : bool
    ◆ static function Button(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function Button(text : string, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function Button(content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : bool    //   描述:制作一个简单的按钮,用户点击它们的时候就会有事情发生。 返回bool – true当用户单击按钮时。

     参数
     text 显示在该按钮上的文本
     image显示在该按钮上的Texture
     content用于这个按钮的文本,图形和提示。
     style 使用的风格。如果不设置,将使用当前的GUISkin的button风格。
     options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight

    ◆ static functioin EndArea() : void    //    描述:关闭由BeginArea开始的GUILayout块

    ◆ static function EndHorizontal() : void    //   描述:关闭一个开始于BeginHorizontal的组

    ◆ static functioin EndScrollView() : void    //     描述:结束由BeginScrollView调用开始的滚动视。

    ◆ static functioin EndVertical() : void    //     描述:关闭一个开始于BeginVertical的组

    ◆ static functioin ExpandHeight(expand : bool) : GUILayoutOption    //   描述:传递给一个空间的选项来允许或不允许垂直扩展。

    ◆ static functioin ExpandWidth(expand : bool) : GUILayoutOption    //    描述:传递给一个空间的选项来允许或不允许水平扩展。

    ◆ static functioin FlexibleSpace() : void     //    描述:插入一个灵活的空格元素  灵活的空格用来填充一个布局中任何遗漏的空间。

    ◆ static functioin Height(height : float) : GUILayoutOption     描述:传递给空间的选项以便给它一个绝对高度。

    ◆ static functioin HorizontalScrollbar(value : float, size : float, leftValue : float, rightValue : float, params options : GUILayoutOption[]) : float
    ◆ static functioin HorizontalScrollbar(value : float, size : float, leftValue : float, rightValue : float, style : GUIStyle, params options : GUILayoutOption[]) : float   //    描述:一个水平滚动条。滚动条可以用来滚动文档。大多数情况下,你会使用滚动视代替。     返回floar – 修改后的值。这可以通过拖动这个滚动条,或者单击两端的箭头来改变。

     参数

     value在min和max之间的位置
     size 能看见多大?
     leftValue滚动条左端的值
     rightValue  滚动条右端的值
     style 用于滚动条背景的风格。如果不设置,将使用当前GUISkin的horizontalScrollbar
     options 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

     参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight

    找到额外的元素:在滚动条两端的按钮将在当前皮肤中搜索“leftButton”和“rightButton”作为风格,滚动条的滑块(你拖动的东西)将搜索并使用名为“thumb”的风格。这将使用下面的风格名来决定该按钮的尺寸/位置,

     scrollPos = GUILayout.HorizontalScrollbar(scrollPos, 1, 0, 100, “MyScrollbar”);

     MyScrollbarleftButton - 用于左侧按钮的风格位置
     MyScrollbarrightButton - 用于右侧按钮的风格位置
     MyScrollbarthumb - 用于滑块的风格名称

    ◆ static functioin HorizontalSlider(value : float, leftValue : float, rightValue : float, params options : GUILayoutOption[]) : float
    ◆ static functioin HorizontalSlider(value : float, leftValue : float, rightValue : float, slider : GUIStyle, thumb : GUIStyle, params options : GUILayoutOption[]) : float  //   描述:一个用户可以拖动的滑杆。可以在min和max之间取一个值。 返回float – 被用户设置的值。

    参数
    value滑块显示的值。这个决定可拖动滑块的位置。
    leftValue滑杆左端的值。
    rightValue  滑杆右边的值。
    slider用于显示拖动区域的GUIStyle。如果不设置,将使用当前GUISkin的horizontalSlider。
 
    thumb  用于显示拖动块的GUISkin。如果不设置,将使用当前的GUISkin的horizontalSliderThumb
    options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Label(image : Texture, params options : GUILayoutOption[]) : void
    ◆ static function Label(text : string, params options : GUILayoutOption[]) : void
    ◆ static function Label(content : GUIContent, params options : GUILayoutOption[]) : void
    ◆ static function Label(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : void
    ◆ static function Label(text : string, style : GUIStyle, params options : GUILayoutOption[]) : void
    ◆ static function Label(content: GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : void   //   描述:制作一个自动布局label  标签没有用户交互。不会获取鼠标点击并总是以普通风格渲染。如果你想制作一个可视化响应用户输出的控件,使用一个Box控件。

    参数
    text 显示在该标签上的文本。
    image显示在标签上的Texture。
    content用于这个标签的文本,图形和提示。
    style 使用的风格。如果不设置。将使用当前GUISkin的label。
    options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.
 
    ◆ static function MaxHeight(maxHeight : float) : GUILayoutOption    //     描述:传递给控件的选项来指定一个最大高度。

    ◆ static function MaxWidth(maxWidth : float) : GUILayoutOption    //   描述:传递给控件的选项来指定一个最大宽度。

    ◆ static function MinHeight(minHeight : float) : GUILayoutOption    //     描述:传递给控件的选项来指定一个最小高度。

    ◆ static function MinWidth(minWidth : float) : GUILayoutOption    //     描述:传递给控件的选项,来指定一个最小宽度

    ◆ static function PasswordField(password : string,  maskChar : char, params options : GUILayoutOption[]) : string
    ◆ static function PasswordField(password : string,  maskChar : char, maxLength : int, params options : GUILayoutOption[]) : string
    ◆ static function PasswordField(password : string,  maskChar : char, style : GUIStyle, params options : GUILayoutOption[]) : string
    ◆ static function PasswordField(password : string,  maskChar : char, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : string  //  描述:制作一个用户可以输入密码的文本域。返回string – 编辑过的密码。

    参数
    password 用于编辑的密码。这个函数返回值应该被赋回这个字符串。
    maskChar 用来隐藏密码的字符。
    maxLength 字符串的最大长度。如果不设置,用户可以一直输入。
    style 使用的风格。如果不设置,将使用当前GUISkin的textField风格。

    如下的例子:
    var passwordToEdit = “My Password”;

    function OnGUI()
    {
      passwordToEdit = GUILayout.PasswordField(passwordToEdit, “*”, 25);// 制作一个密码与来调整stringToEdit。
    }

    ◆ static function RepeatButton(image : Texture, params options : GUILayoutOption[]) : bool
    ◆ static function RepeatButton(text : string, params options : GUILayoutOption[]) : bool
    ◆ static function RepeatButton(content : GUIContent, params options : GUILayoutOption[]) : bool
    ◆ static function RepeatButton(image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function RepeatButton(text : string, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function RepeatButton(content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : bool  //   描述:制作一个重复按钮,只要用户按住鼠标这个按钮一直返回真。 返回bool - /true/当用户按住按钮时

    参数
    text显示在该按钮上的文本。
    image  显示在该按钮上的Texture。
    content  用于这个按钮的文本,图形和提示。
    style使用的风格,如果不设置,将使用当前GUISkin的button风格。
    options  一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

     参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function SeletionGrid(selected : int, texts : string[], xCount : int, params options : GUILayoutOption[]) : int
    ◆ static function SeletionGrid(selected : int, images : Texture[], xCount : int, params options : GUILayoutOption[]) : int
    ◆ static function SeletionGrid(selected : int, contents : GUIContent[], xCount : int, params options : GUILayoutOption[]) : int
    ◆ static function SeletionGrid(selected : int, texts : string[], xCount : int, style : GUIStyle, params options : GUILayoutOption[]) : int
    ◆ static function SeletionGrid(selected : int, images : Texture[], xCount : int, style : GUIStyle, params options : GUILayoutOption[]) : int
    ◆ static function SeletionGrid(selected : int, contents : GUIContent[], xCount : int, style : GUIStyle, params options : GUILayoutOption[]) : int  //描述:制作一个选择网格  返回int – 选择按钮的索引

    参数
    selected选择按钮的索引
    texts 显示在按钮的字符串数组。
    images在按钮上纹理数组
    contents用于按钮的文本,图形和提示。
    xCount  在水平方向多少个元素,元素将被缩放来适应,除非风格定义了一个fixedWidth,空间高度将由元素的数量决定。
    style 使用的风格。如果不设置,将使用当前GUISkin的button风格。
    options 一个可选的布局选项的列表,它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Space(pixel : float) : void    //     描述:在当前布局组中插入一个空格, 空格的方向依赖与使用这个命令时当前所在布局组。如果在垂直组,空格是垂直的。

    function OnGUI()
    {
     GUILayout.Button(“I’m the first button”);
    
     GUILayout.Space(20);    //    在两个按钮间插入20像素
  
     GUILayout.Button(“I’m a bit futher down”);
    }

     在水平组,pixels将是水平的;

     function OnGUI()
     {

      GUILayout.BeginHorizontal(“box”);   //      开始水平组以便显示水平空格
      GUILayout.Button(“I’m the first button”);
      GUILayout.Space(20);   //    在两个按钮间插入20像素
      GUILayout.Button(“I’m to the right”);
      GUILayout.EndHorizontal();    //   结束上面开始的水平组
    }

    ◆ static function TextArea(text : string, params options : GUILayoutOption[]) : string
    ◆ static function TextArea(text : string, maxLength : int, params options : GUILayoutOption[]) : string
    ◆ static function TextArea(text : string, style : GUIStyle, params options : GUILayoutOption[]) : string
    ◆ static function TextArea(text : string, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : string   //     描述:制作一个多行文本域。这里用户可以编辑这个字符串。 返回string – 编辑过的字符串。

    参数
    text  用于编辑的文本。这个函数返回值应该被赋回这个字符串。如下的例子。
    maxLength  字符串的最大长度。如果不设置,用户可以一直输入。
    style 使用的风格。如果不设置,则使用当前GUISkin的textField风格。
    options 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.


    ◆ static function TextField(text : string, params options : GUILayoutOption[]) : string
    ◆ static function TextField (text : string, maxLength : int, params options : GUILayoutOption[]) : string
    ◆ static function TextField (text : string, style:GUIStyle, params options : GUILayoutOption[]) : string
    ◆ static function TextField (text : string, maxLength : int, style : GUIStyle, params options : GUILayoutOption[]) : string    //    描述:制作一个单行文本域。这里用户可以编辑这个字符串。返回string – 编辑过的字符串。

    参数
    text  用于编辑的文本。这个函数返回值应该被赋回这个字符串,如下的例子。
    maxLength  字符串的最大长度。如果不设置,用户可以一直输入。
    style 使用的风格。如果不设置,将使用当前的GUISkin的textArea
    options  一个可选的布局选项的列表,它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    var stringToEdit = “Hello, world”;

    function OnGUI()
    {
     stringToEdit = GUILayout.TextField(stringToEdit, 25);  //制作一个文本域来调整stringToEdit
    } 

    ◆ static function Toogle(value : bool, image : Texture, params options : GUILayoutOption[]) : bool
    ◆ static function Toogle(value : bool, text : string, params options : GUILayoutOption[]) : bool
    ◆ static function Toogle(value : bool, content : GUIContent, params options : GUILayoutOption[]) : bool
    ◆ static function Toogle(value : bool, image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function Toogle(value : bool, text : string, style : GUIStyle, params options : GUILayoutOption[]) : bool
    ◆ static function Toogle(value : bool, content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : bool   //    描述:制作一个on/off开关按钮。  返回bool – 按钮的新值

    参数
    value按钮是打开或关闭
    text 显示在该按钮上的文本
    image显示在该按钮上的Texture
    content用于这个按钮的文本,图形和提示
    style 使用的风格。如果不设置,将使用当前GUISkin的button风格。
    options  一个可选的布局选项的列表,它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Toolbar(selected: int, texts : string[], params options : GUILayoutOption[]) : int
    ◆ static function Toolbar(selected: int, images : Texture[], params options : GUILayoutOption[]) : int
    ◆ static function Toolbar(selected: int, contents: GUIContent[], params options : GUILayoutOption[]) : int
    ◆ static function Toolbar(selected: int, texts : string[], style : GUIStyle, params options : GUILayoutOption[]) : int
    ◆ static function Toolbar(selected: int, image : Texture[],style : GUIStyle, params options : GUILayoutOption[]) : int
    ◆ static function Toolbar(selected: int, content : GUIContent[],style : GUIStyle, params options : GUILayoutOption[]) : int    //    描述:制作一个工具栏   返回int – 选择按钮的索引

    参数

    selected选择按钮的索引
    texts 显示在按钮上的字符串数组
    images在按钮上的纹理数组
    contents用于按钮的文本,图形和提示数组
    style 使用的风格。如果不设置,将使用当前GUISkin的button风格。
    options 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function VerticalScrollbar(value: float, size : float, topValue : float, buttomValue : float, params options : GUILayoutOption[]) : float
    ◆ static function VerticalScrollbar(value: float, size : float, topValue : float, buttomValue : float, style : GUIStyle, params options : GUILayoutOption[]) : float   // 描述:制作一个垂直滚动条。滚动条可以用来滚动文档。大多数情况下,你会使用scollView代替。返回float – 修改后的值。这可以通过拖动这个滚动条,或者单击两端的箭头来改变。

     参数
     value在min和max之间的位置
     size 能看见多大?
     topValue滚动条顶端的值
     bottomValue  滚动条底端的值
     style  用于滚动条背景的风格。如果不设置,将使用当前GUISkin的horizontalScrollbar。
     options 一个可选的布局选项的列表。它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

    参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

     找到额外的元素: 在滚动条两端的按钮将在当前皮肤中搜索“upbutton”和“downbutton”作为风格。滚动条的滑块(你拖动的东西)将搜索并使用名为thumb的风格。

    这将使用下面的风格名来决定该按钮的尺寸/位置

    MyVerticalScrollbarupbutton – 用于顶端按钮的风格名称
    MyVerticalScrollbardownbutton – 用于底端按钮的风格名称
    MyScrollbarthumb – 用于滑块的风格名称
    scrollPos = GUILayout.HorizontalScrollbar(scrollPos, 1, 0, 100, “MyVerticalScrollbar”);


    ◆ static function VerticalSlider(value : floar, leftValue : float, rightValue : float, params options : GUILayoutOption[]) : float
    ◆ static function VerticalSlider(value : floar, leftValue : float, rightValue : float, slider : GUIStyle, thumb : GUIStyle, params options : GUILayoutOption[]) : float

    参数
     value滑杆显示的值。这个决定可拖动滑块的位置。
     topValue滑杆顶端的值。
     downValue  滑杆底端的值。
     slider  用于显示拖动区域的GUIStyle。如果不设置,将使用当前GUISkin的horizontalSlider。
     thumb  用于显示拖动块的GUIStyle。如果不设置,将使用当前的GUISkin的horizontalSliderThumb。
     options  一个可选的布局选项的列表,它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

     参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    ◆ static function Width(width : float) : GUILayoutOption    //    描述:传递给控件的选项以便给它一个绝对宽度

    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, text : string) : Rect
    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, image : Texture) : Rect
    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, content : GUIContent) : Rect
    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, text : string, style : GUIStyle) : Rect
    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, image : Texture, style : GUIStyle) : Rect
    ◆ static function Window(id : int, screenRect : Rect, func : GUIWindowFunction, content : GUIContent, style : GUIStyle) : Rect    //   描述:制作一个弹出窗口。它的内容是自动布局的。 返回Rect – 窗口位于举行位置。这个可能与你传入的一个具有不同位置和尺寸。

    参数
     id 用于每个窗口唯一的ID。这是用于接口的ID。
     clientRect  屏幕上用于窗口的矩形区域。布局系统将试图使窗体在他内部。如果不能,它将调整矩形去适应它
     func  在窗体内部创建GUI的函数。这个函数必须使用一个函数 – 当前创建GUI的窗体id。
     image 用于在标题栏上显示图片的Texture。
     content 用于这个窗口的文本,图形和提示。
     style 使用的风格。如果不设置,将使用当前GUISkin的button风格。
     options  一个可选的布局选项的列表,它用来指定额外的布局属性。任何在这里设置的值将覆盖由style定义的设置。

     参见:GUILayout.Width,  GUILayout.Height,  GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

    窗口浮动在普通GUI控件之上。具有单击激活的特点并可以有选择的随意被用户拖动。不像其他的控件,你需要传递给他们一个独立的功能并放置在窗口中这儿是一个小例子来帮助你开始:

    var windowRect = Rect(20, 20, 120, 50);
    function OnGUI()
    {
     windowRect = GUILayout.Window(0, windowsRect, DoMyWindow, “My Window”);   //注册窗口,注意第三个参数
    }

    function DoMyWindow(windowed : int)    //制作窗口内容
    {
     if(GUILayout.Button(“Hello World”))     //这个按钮将调整以适应物体
      print(“Get a click”);
    }

    你传入的客户区域只是作为一个参考,为了对窗口使用额外的限制。闯入一些额外的布局选项。用在这里的一个将覆盖尺寸的计算。这是一个简单的例子。

    var windowRect = Rect(20, 20, 120, 50);
    function OnGUI()
    {
     windowRect = GUILayout.Window(0, windowRect, DoMyWindow, “My Window”, GUILayout.width(100));  //注册窗口,这里我们指示布局系统必须使窗体为100像素宽。
    }

    function DoMyWindow(windowID : int)    //制作窗体内容
    { 
    if(GUILayout.Button(“Please click me a lot”))   //  这个按钮大小不能适应这个窗体   /通常,这个窗体将被扩展以便适应这个按钮。但是由于GUILayout.Width将只允许窗体为100像素宽
    print(“Get a click”);
    }

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值