Мои Уведомления
Привет, !
Мой Аккаунт Мои Финансы Мои Подписки Мои Настройки Выход
Руководство API скрипты

EditorGUI.BoundsField

Объявление

public static Bounds BoundsField(Rect position, Bounds value);

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

Параметры

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

Возвращает

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

Описание

Создает поле Center and Extents для ввода Границы.

Поле Bounds в окне редактора.

См. так же Extending the editor.

using UnityEngine; using UnityEditor; // Простой скрипт, показывающий радиус границ выбранного MeshFilter class EditorGUILayoutBoundsField : EditorWindow { float radius = 0; Bounds bounds; [MenuItem("Examples/Show Radius of mesh bounds")] static void Init() { var window = GetWindow(); window.Show(); } void 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) { 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(); } } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3