EditorGUI.BoundsField 边界盒字段


static function BoundsField (position : Rect, value : Bounds) : Bounds
static function BoundsField (position : Rect, label : GUIContent, value : Bounds) : Bounds

Parameters参数

  • position
    Rectangle on the screen to use for the field.
    屏幕上的矩形区域    
  • label
    Optional label to display above the field.
       该字段上面显示的可选标签    
  • value
    The value to edit. // 编辑的值

Returns

Bounds - The value entered by the user.

返回Bounds - 用户输入的值。

Description描述

Make Center & Extents field for entering a Bounds.

制作Center 和 Extents字段,用来输入一个Bounds。

EditorGUI.BoundsField 边界盒字段

Bounds field in an Editor Window.

在编辑器窗口中的边界盒字段。

// Simple script that shows radius of bounds of selected MeshFilter//显示选择的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();}}


,