Version: 2017.3
public static Bounds BoundsField (Rect position, Bounds value);
public static Bounds BoundsField (Rect position, GUIContent label, Bounds value);

Parameters

position @param position Прямоугольник на экране, используемый для поля.
label @param label Необязательный текст, отображаемый над полем.
value @param value Значение для редактирования.

Returns

Bounds Значение, введенное пользователем.

Description

Создает поле Center & Extents для ввода границ Bounds.


Bounds field in an Editor Window.

See also Extending the editor.

// Simple script that shows radius of bounds of selected MeshFilter

class EditorGUILayoutBoundsField extends EditorWindow {

var radius : float = 0; var bounds : Bounds;

@MenuItem("Examples/Show Radius of mesh bounds") static function Init() { var window = GetWindow(EditorGUILayoutBoundsField); window.Show(); }

function OnGUI() { GUILayout.Label("Select a mesh in the Hierarchy view and click 'Capture Bounds'"); EditorGUILayout.BeginHorizontal(); bounds = EditorGUILayout.BoundsField("Mesh bounds:", bounds); if(GUILayout.Button("Capture Bounds") && Selection.activeTransform) { var meshFilter : MeshFilter = Selection.activeTransform.GetComponentInChildren(MeshFilter); if (meshFilter) bounds = meshFilter.sharedMesh.bounds; } EditorGUILayout.EndHorizontal();

EditorGUILayout.LabelField("Radius:", bounds.size.magnitude.ToString()); if(GUILayout.Button("Close")) this.Close(); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961