public static Rect RectField (Rect position, Rect value);
public static Rect RectField (Rect position, string label, Rect value);
public static Rect RectField (Rect position, GUIContent label, Rect value);

Parameters

position 屏幕上用于字段的矩形。
label (可选)显示在字段上方的标签。
value 要编辑的值。

Returns

Rect 用户输入的值。

Description

创建用于输入 Rect 的 X、Y、W 和 H 字段。


Rect field in an Editor Window.


// Find all the cameras in the scene and shows all their viewports togheter

class EditorGUIRectField extends EditorWindow {

var cameras : Camera[];

@MenuItem("Examples/Editor GUI RectField usage") static function Init() { var window = GetWindow(EditorGUIRectField); window.position = Rect(0,0,150,120); window.Show(); }

function OnGUI() { if(GUI.Button(Rect(3,3,position.width-6,20),"Update list")) cameras = FindObjectsOfType(Camera);

if(cameras) for(var i = 0; i < cameras.Length; i++) { cameras[i].rect = EditorGUI.RectField( Rect(3,25+45*i,position.width - 6, 25), cameras[i].name, cameras[i].rect); } } }

Description

使用 SerializedProperty(非公开)生成矩形的 X、Y、W 和 H。