返回介绍

GUILayout.SelectionGrid 选择表格

发布于 2019-12-18 15:37:47 字数 5817 浏览 1139 评论 0 收藏 0

JavaScript => public static function SelectionGrid(selected: int, texts: string[], xCount: int, params options: GUILayoutOption[]): int;
JavaScript => public static function SelectionGrid(selected: int, images: Texture[], xCount: int, params options: GUILayoutOption[]): int;
JavaScript => public static function SelectionGrid(selected: int, content: GUIContent[], xCount: int, params options: GUILayoutOption[]): int;
JavaScript => public static function SelectionGrid(selected: int, texts: string[], xCount: int, style: GUIStyle, params options: GUILayoutOption[]): int;
JavaScript => public static function SelectionGrid(selected: int, images: Texture[], xCount: int, style: GUIStyle, params options: GUILayoutOption[]): int;
JavaScript => public static function SelectionGrid(selected: int, contents: GUIContent[], xCount: int, style: GUIStyle, params options: GUILayoutOption[]): int;
C# => public static int SelectionGrid(int selected, string[] texts, int xCount, params GUILayoutOption[] options);
C# => public static int SelectionGrid(int selected, Texture[] images, int xCount, params GUILayoutOption[] options);
C# => public static int SelectionGrid(int selected, GUIContent[] content, int xCount, params GUILayoutOption[] options);
C# => public static int SelectionGrid(int selected, string[] texts, int xCount, GUIStyle style, params GUILayoutOption[] options);
C# => public static int SelectionGrid(int selected, Texture[] images, int xCount, GUIStyle style, params GUILayoutOption[] options);
C# => public static int SelectionGrid(int selected, GUIContent[] contents, int xCount, GUIStyle style, params GUILayoutOption[] options);

Parameters 参数

selectedThe index of the selected button.
被选择按钮的索引
textsAn array of strings to show on the buttons.
显示在按钮上的字符串的数组。
imagesAn array of textures on the buttons.
显示在按钮上的纹理的数组
contentsAn array of text, image and tooltips for the button.
用于这个按钮的文本、图片和工具提示的数组。
xCountHow many elements to fit in the horizontal direction. The elements will be scaled to fit unless the style defines a fixedWidth to use. The height of the control will be determined from the number of elements.
有多少元素适配水平方向。每个元素将自动缩放适配,除非样式应用了固定宽度,控件的高度取决于从元素的数量。
styleThe style to use. If left out, the button style from the current GUISkin is used.
使用的样式。如果不使用,该开关按钮使用当前的GUISkin皮肤
optionsAn optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
布局选项指定额外布局属性的一个可选列表。这里传递任意值都将覆盖由style定义的设置。

Returns返回

int The index of the selected button.

返回整数型,被选择按钮的索引。

Description 描述

Make a Selection Grid.

创建一个选择表格。

JavaScript:

var selGridInt : int = 0;
var selStrings : String[] = ["radio1", "radio2", "radio3"];
 
function OnGUI() {
    GUILayout.BeginVertical("Box");
    selGridInt = GUILayout.SelectionGrid (selGridInt, selStrings, 1);
    if (GUILayout.Button("Start")){
      Debug.Log("You chose " + selStrings[selGridInt]);
    }
    GUILayout.EndVertical();
}

C#:

using UnityEngine;
using System.Collections;
 
public class ExampleClass : MonoBehaviour {
    public int selGridInt = 0;
    public string[] selStrings = new string[] {"radio1", "radio2", "radio3"};
    void OnGUI() {
        GUILayout.BeginVertical("Box");
        selGridInt = GUILayout.SelectionGrid(selGridInt, selStrings, 1);
        if (GUILayout.Button("Start"))
            Debug.Log("You chose " + selStrings[selGridInt]);
 
        GUILayout.EndVertical();
    }
}

guilayout

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文