お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
Closeposition | グリッドを描画するスクリーン上のRect |
selected | 選択したグリッドボタンのインデックス |
texts | グリッドボタン上に表示する文字列配列 |
images | グリッドボタン上に表示するテクスチャ配列 |
contents | グリッドボタンのテキスト、画像、ツールチップとなるGUIContent配列 |
xCount | 水平に並べる要素の数。コントロールはスタイルに定義されているfixedWidthを使用しない限りフィットするように大きさが拡大縮小されます |
style | 使用するスタイル。省略された場合は、現在のGUISkinにある button スタイルを使用します。 |
int 選択したボタンのインデックスを返します
選択グリッドボタン
var selGridInt : int = 0; var selStrings : String[] = ["Grid 1", "Grid 2", "Grid 3", "Grid 4"]; function OnGUI () { selGridInt = GUI.SelectionGrid (Rect (25, 25, 100, 30), selGridInt, selStrings, 2); }
using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public int selGridInt = 0; public string[] selStrings = new string[] {"Grid 1", "Grid 2", "Grid 3", "Grid 4"}; void OnGUI() { selGridInt = GUI.SelectionGrid(new Rect(25, 25, 100, 30), selGridInt, selStrings, 2); } }
import UnityEngine import System.Collections public class ExampleClass(MonoBehaviour): public selGridInt as int = 0 public selStrings as (string) = (of string: 'Grid 1', 'Grid 2', 'Grid 3', 'Grid 4') def OnGUI() as void: selGridInt = GUI.SelectionGrid(Rect(25, 25, 100, 30), selGridInt, selStrings, 2)