public static float Slider (float value, float leftValue, float rightValue, params GUILayoutOption[] options);
public static float Slider (string label, float value, float leftValue, float rightValue, params GUILayoutOption[] options);
public static float Slider (GUIContent label, float value, float leftValue, float rightValue, params GUILayoutOption[] options);

参数

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

返回

float 用户设置的值。

描述

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


在一定范围内缩放所选对象。

// Editor script that lets you scale the selected GameObject between 1 and 100

using UnityEditor; using UnityEngine;

public class EditorGUILayoutSlider : EditorWindow { static float scale = 0.0f;

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

void OnGUI() { scale = EditorGUILayout.Slider(scale, 1, 100); }

void OnInspectorUpdate() { if (Selection.activeTransform) Selection.activeTransform.localScale = new Vector3(scale, scale, scale); } }

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

参数

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

描述

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