Version: 2021.3
public static int IntSlider (int value, int leftValue, int rightValue, params GUILayoutOption[] options);
public static int IntSlider (string label, int value, int leftValue, int rightValue, params GUILayoutOption[] options);
public static int IntSlider (GUIContent label, int value, int leftValue, int rightValue, params GUILayoutOption[] options);

参数

label (可选)滑动条前的标签。
value 滑动条显示的值。该值决定可拖动滑块的位置。
leftValue 滑动条左端的值。
rightValue 滑动条右端的值。
options 一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

返回

int 用户设置的值。

描述

创建一个滑动条,用户可以进行拖动以在最小值和最大值之间更改整数值。


创建克隆对象的网格。

using UnityEditor;
using UnityEngine;

// Simple editor script that lets you clone your object in a grid

public class IntSliderExample : EditorWindow { int cloneTimesX = 1; int cloneTimesY = 1; int cloneTimesZ = 1; int spacing = 2;

[MenuItem("Examples/Editor GUILayout IntSlider usage")] static void Init() { EditorWindow window = GetWindow(typeof(IntSliderExample)); window.Show(); }

void OnGUI() { cloneTimesX = EditorGUILayout.IntSlider(cloneTimesX, 1, 10); cloneTimesY = EditorGUILayout.IntSlider(cloneTimesY, 1, 10); cloneTimesZ = EditorGUILayout.IntSlider(cloneTimesZ, 1, 10);

if (GUILayout.Button("Duplicate object")) CloneSelected(); }

void CloneSelected() { if (!Selection.activeGameObject) { Debug.LogError("Select a GameObject first"); return; }

for (int i = 0; i < cloneTimesX; i++) for (int j = 0; j < cloneTimesY; j++) for (int k = 0; k < cloneTimesZ; k++) Instantiate(Selection.activeGameObject, new Vector3(i, j, k) * spacing, Selection.activeGameObject.transform.rotation); } }

public static void IntSlider (SerializedProperty property, int leftValue, int rightValue, params GUILayoutOption[] options);
public static void IntSlider (SerializedProperty property, int leftValue, int rightValue, string label, params GUILayoutOption[] options);
public static void IntSlider (SerializedProperty property, int leftValue, int rightValue, GUIContent label, params GUILayoutOption[] options);

参数

label (可选)滑动条前的标签。
property 滑动条显示的值。该值决定可拖动滑块的位置。
leftValue 滑动条左端的值。
rightValue 滑动条右端的值。
options 一个可选的布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 style 定义的设置。
另请参阅:GUILayout.WidthGUILayout.HeightGUILayout.MinWidthGUILayout.MaxWidthGUILayout.MinHeightGUILayout.MaxHeightGUILayout.ExpandWidthGUILayout.ExpandHeight

描述

创建一个滑动条,用户可以进行拖动以在最小值和最大值之间更改整数值。


Did you find this page useful? Please give it a rating: