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

EditorGUI.IntField

Объявление

public static int IntField(Rect position, int value, GUIStyle style = EditorStyles.numberField);

public static int IntField(Rect position, string label, int value, GUIStyle style = EditorStyles.numberField);

public static int IntField(Rect position, GUIContent label, int value, GUIStyle style = EditorStyles.numberField);

Параметры

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

Возвращает

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

Описание

Создает текстовое поле для ввода целых чисел.

Поле Int в окне редактора.
//Создайте папку и назовите ее "Editor" (щелкните правой кнопкой мыши в папке проекта Asset и выберите "Создать"). Папка), если у вас ее еще нет //Поместите этот скрипт в папку Editor //Этот скрипт создает новое меню в верхней части Редактора под названием "Примеры" с одним пунктом "Клонировать объект". using UnityEngine; using UnityEditor; class Example : EditorWindow { int clones = 1; [MenuItem("Examples/Clone Object")] static void Init() { //Create the new Editor window and show it EditorWindow window = GetWindow(typeof(Example)); window.Show(); } void OnGUI() { //The field which allows you to input the amount of clones of a GameObject you want clones = EditorGUI.IntField(new Rect(0, 35, position.width, 15), "Number of clones:", clones); //If there isn't a currently selected GameObject, this message appears if (Selection.activeGameObject == null) EditorGUI.LabelField(new Rect(3, 3, position.width, 20), "Please click on a GameObject in your Scene!"); //Press the clone Button if (GUI.Button(new Rect(0, 55, position.width, 20), "Clone!")) { //Check that you have a GameObject selected if (Selection.activeGameObject != null) { //Loop until the number of clones is reached for (int i = 0; i < clones; i++) { //Spawn each of the clones Instantiate(Selection.activeGameObject, Vector3.zero, Quaternion.identity); } } } } }
Вы можете отблагодарить автора, за перевод документации на русский язык. ₽ Спасибо
API скрипты 2021.3