EditorGUI.RectField Manual     Reference     Scripting  
Scripting > Editor Classes > EditorGUI
EditorGUI.RectField

static function RectField (position : Rect, value : Rect) : Rect

static function RectField (position : Rect, label : String, value : Rect) : Rect

static function RectField (position : Rect, label : GUIContent, value : Rect) : Rect

Parameters

NameDescription
position Rectangle on the screen to use for the field.
label Optional label to display above the field.
value The value to edit.

Returns

Rect - The value entered by the user.

Description

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


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);
}
}
}