EditorGUILayout.RectField 矩形字段

static function RectField (value : Rect, params options : GUILayoutOption[]) : Rect
static function RectField (label : string, value : Rect, params options : GUILayoutOption[]) : Rect
static function RectField (label : GUIContent, value : Rect, params options : GUILayoutOption[]) : Rect

Parameters参数

Returns

Rect - The value entered by the user.

返回Rect,由用户输入的值。

Description描述

Make an X, Y, W & H field for entering a Rect.

制作 X, Y, W & H字段用于输入矩形。

EditorGUILayout.RectField 矩形字段

Modify Another's window position and size values.
修改其他窗口位置和大小的值。

// Simple Script that lets you modify another's window position value
//修改其他窗口位置的值
// To use this script you need to open first the DummyWindow window.
//使用这个脚本必须首先打开DummyWindow窗口
class MoveResizeSelectedWindow extends EditorWindow {

	var pos : Rect;

	@MenuItem("Examples/Move - Resize other window")
	static function Init() {
		var window = GetWindow(MoveResizeSelectedWindow);
		window.Show();
	}

	function OnGUI() {
		DummyWindow.instance.position =
			EditorGUILayout.RectField("Window's position:",
				DummyWindow.instance.position);
		if(GUILayout.Button("Reset position"))
			DummyWindow.instance.position = Rect(0,0,200,200);
		if(GUILayout.Button("Close"))
			this.Close();
	}
}

And the script that works with the example:

窗口的例子

// Dummy window that is going to be moved.
//窗口将被移动
class DummyWindow extends EditorWindow {

	static var instance;
	@MenuItem("Examples/Dummy Window")
	static function Init() {
		var window = GetWindow(DummyWindow);
		window.Show();
	}
	function DummyWindow() {
		instance = this;
	}
}
最后修改:2011年7月14日 Thursday 17:14

本脚本参考基于Unity 3.4.1f5

英文部分版权属©Unity公司所有,中文部分© Unity圣典 版权所有,未经许可,严禁转载 。