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
对应每个窗口的特有索引号。
screenRect
窗口所在的矩形区域。
func
窗口内部的绘制函数,该函数必须只能接受一个参数,就是要绘制窗口的索引号。
text
区域内要显示的文字。
image
区域内要显示的图片。
content
区域内要显示的文本、图片或者小提示。
style
(可选)该区域的样式。
options
(可选)用于指定额外的布局属性,该参数将覆盖默认样式。
示例
pprivate void OnSceneGUI () {
Handles.BeginGUI ();
_window = GUILayout.Window (0, _window, OnWindowGUI, "Window");
Handles.EndGUI ();
}
private void OnWindowGUI(int id) {
GUILayout.Button ("Button");
GUI.DragWindow ();
}