EditorWindow.EndWindows 结束窗口

function EndWindows () : void

Description描述

Close a window group started with EditorWindow.BeginWindows

关闭一个开始于EditorWindow.BeginWindows的窗口组。

Simple editor Window with a window and a button inside.

带有一个窗口和一个按钮的简单编辑器窗口。

class GUIWindowDemo extends EditorWindow {

	// The position of the window

	//窗口的位置

	var windowRect = Rect (100,100,200,200);



	// Main GUI Function //主GUI函数

	function OnGUI () {

		// Begin Window

		BeginWindows ();



		// All GUI.Window or GUILayout.Window must come inside here

		//所有GUI.Window 或 GUILayout.Window 必须在这里面

		windowRect = GUILayout.Window (1, windowRect, DoWindow, "Hi There");



		// Collect all the windows between the two.

		//在这两者之间搜集所有窗口

		EndWindows ();

	}



	// The window function. This works just like ingame GUI.Window

	//窗口函数,这就像游戏内的GUI.Window

	function DoWindow () {

		GUILayout.Button ("Hi");

		GUI.DragWindow ();

	}



	// Add menu item to show this demo.

	//添加菜单项来显示这个演示

	@MenuItem ("Test/GUIWindow Demo")

	static function Init () {

		EditorWindow.GetWindow (GUIWindowDemo);

	}

}

The placement of the BeginWindows / EndWindows pair determines where popup windows will appear; all windows are clipped to the clipping area defined by GUI.BeginGroup or GUI.BeginScrollview. A small example of that

BeginWindows / EndWindows对的放置决定弹出窗口的显示。所有窗口都放到GUI.BeginGroupGUI.BeginScrollview中定义。一个简单的例子:

EditorWindow.BeginWindows 开始窗口

Simple editor window with a window and a button inside using scroll bars.

带有一个窗口和一个按钮,使用滚动条的简单编辑器窗口。

class GUIWindowDemo2 extends EditorWindow {

	// The position of the window

	//窗口的位置

	var windowRect = Rect (100,100,200,200);



	// Scroll position 滚动位置

	var scrollPos = Vector2.zero;



	function OnGUI () {

		// Set up a scroll view 设置滚动视图

		scrollPos = GUI.BeginScrollView (

			new Rect (0, 0, position.width, position.height),

			scrollPos,

			new Rect (0, 0, 1000, 1000)

		);



		// Same code as before - make a window. Only now, it's INSIDE the scrollview

		//创建一个窗口,仅限在,在滚动视图中

		BeginWindows ();

		windowRect = GUILayout.Window (1, windowRect, DoWindow, "Hi There");

		EndWindows ();



		// Close the scroll view 关闭滚动视图

		GUI.EndScrollView ();

	}



	function DoWindow () {

		GUILayout.Button ("Hi");

		GUI.DragWindow ();

	}



	@MenuItem ("Test/GUIWindow Demo 2")

	static function Init () {

		EditorWindow.GetWindow (GUIWindowDemo2);

	}

}
Page last updated: 2011-5-29