Version: 5.6
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);

Parámetros

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

Valor de retorno

Rect The value entered by the user.

Descripción

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

Descripción

Make an X, Y, W & H for Rect using SerializedProperty (not public).

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961