id | ウィンドウごとのユニークな ID。これはウィンドウのインターフェースで使用します |
screenRect | ウィンドウで使用するスクリーンの Rect。レイアウトシステムは screenRect の中にウィンドウが収まるようにします - もし収めることができない場合には、Rect を調整する必要があります |
func | ウィンドウの内側の GUI を作成する関数。この関数は GUI を作成するためのウィンドウの id をパラメーターとして持ちます |
text | ウィンドウのタイトルとして表示されるテキスト |
image | タイトルバー上に表示する Texture |
content | ウィンドウのテキスト、画像、ツールチップ |
style | ウィンドウに使用するスタイル。省略された場合は、現在の GUISkin にある toggle スタイルを使用します |
options | An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style or the screenRect you pass in.See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight. |
Rect ウィンドウの Rect を返します。これは引数とし t 渡した値とは異なる位置とサイズと持つことができます。
ウィンドウ内のコンテンツが自動でレイアウトされるポップアップウィンドウ
Windows float above normal GUI controls, feature click-to-focus and can optionally be dragged around by the end user.
Unlike other controls, you need to pass them a separate function for the GUI controls to put inside the window. Here is a small example to get you started:
Window in the Game View.
using UnityEngine;
public class ExampleScript : MonoBehaviour { Rect windowRect = new Rect(20, 20, 120, 50);
void OnGUI() { // Register the window. Notice the 3rd parameter windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "My Window"); }
// Make the contents of the window void DoMyWindow(int windowID) { // This button will size to fit the window if (GUILayout.Button("Hello World")) { print("Got a click"); } } }
関数に渡すスクリーン Rect は、道案内のような役割として機能します。ウィンドウに特別な制限を適用するには、特別なレイアウトオプションを渡します。ここで適用されたオプションは計算されたサイズを上書きします。以下のような例です。
using UnityEngine;
public class ExampleScript : MonoBehaviour { Rect windowRect = new Rect(20, 20, 120, 50);
void OnGUI() { // Register the window. Here we instruct the layout system to // make the window 100 pixels wide no matter what. windowRect = GUILayout.Window(0, windowRect, DoMyWindow, "My Window", GUILayout.Width(100)); }
// Make the contents of the window void DoMyWindow(int windowID) { // This button is too large to fit the window // Normally, the window would have been expanded to fit the button, but due to // the GUILayout.Width call above the window will only ever be 100 pixels wide if (GUILayout.Button("Please click me a lot")) { print("Got a click"); } } }
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.