EditorGUILayout.Vector2Field 二维向量字段

static function Vector2Field (label : string, value : Vector2, params options : GUILayoutOption[]) : Vector2

Parameters参数

Returns

Vector2 - The value entered by the user.

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

Description描述

Make an X & Y field for entering a Vector2.

制作X & Y字段用于输入Vector2。

EditorGUILayout.Vector2Field 二维向量字段

Measure the distance between 2 points.
测量2点之间的距离。

// Simple Script that measures the distance between 2 points

//测量2点之间的距离。

class EditorGUILayoutVector2Field extends EditorWindow {



	var distance : float = 0;

	var p1 : Vector2;

	var p2 : Vector2;



	@MenuItem("Examples/Measure Distance")

	static function Init() {

	var window = GetWindow(EditorGUILayoutVector2Field);

	window.Show();

	}

	function OnGUI() {

		p1 = EditorGUILayout.Vector2Field("Point 1:", p1);

		p2 = EditorGUILayout.Vector2Field("Point 2:", p2);

		EditorGUILayout.LabelField("Distance:", distance.ToString());

		if(GUILayout.Button("Close"))

			this.Close();

	}

	function OnInspectorUpdate() {

		distance = Vector2.Distance(p1,p2);

		this.Repaint();

	}

}
Page last updated: 2011-7-14