Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

GUILayout.Window

マニュアルに切り替える
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, string text, params GUILayoutOption[] options);
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, Texture image, params GUILayoutOption[] options);
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, params GUILayoutOption[] options);
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, string text, GUIStyle style, params GUILayoutOption[] options);
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, Texture image, GUIStyle style, params GUILayoutOption[] options);
public static Rect Window(int id, Rect screenRect, GUI.WindowFunction func, GUIContent content, GUIStyle style, params GUILayoutOption[] options);

パラメーター

id ウィンドウごとのユニークな ID。これはウィンドウのインターフェースで使用します
screenRect ウィンドウで使用するスクリーンの Rect。レイアウトシステムは screenRect の中にウィンドウが収まるようにします - もし収めることができない場合には、Rect を調整する必要があります
func ウィンドウの内側の GUI を作成する関数。この関数は GUI を作成するためのウィンドウの id をパラメーターとして持ちます
text ウィンドウのタイトルとして表示されるテキスト
image タイトルバー上に表示する Texture
content ウィンドウのテキスト、画像、ツールチップ
style ウィンドウに使用するスタイル。省略された場合は、現在の GUISkin にある toggle スタイルを使用します
options 特別なレイアウトプロパティーのオプションリスト。ここに渡された値で style で定義された設定を上書きします。 See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

戻り値

Rect ウィンドウの Rect を返します。これは引数とし t 渡した値とは異なる位置とサイズと持つことができます。

説明

ウィンドウ内のコンテンツが自動でレイアウトされるポップアップウィンドウ

ウィンドウは通常の GUI コントロールより上に浮いているようになっており、クリックしてフォーカスされ、必要に応じてユーザーの手でドラッグすることができます。 他のコントロールとは異なり、ウィンドウ内に GUI コントロールを描画するために別の関数を渡す必要があります。以下は始めるための小さな例です。


ゲームビューのウィンドウ

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Rect windowRect = new Rect(20, 20, 120, 50); void OnGUI() { windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "My Window"); } void DoMyWindow(int windowID) { if (GUILayout.Button("Hello World")) print("Got a click"); } }

関数に渡すスクリーン Rect は、道案内のような役割として機能します。ウィンドウに特別な制限を適用するには、特別なレイアウトオプションを渡します。ここで適用されたオプションは計算されたサイズを上書きします。以下のような例です。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Rect windowRect = new Rect(20, 20, 120, 50); void OnGUI() { windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "My Window", GUILayout.Width(100)); } void DoMyWindow(int windowID) { if (GUILayout.Button("Please click me a lot")) print("Got a click"); } }