Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

EditorGUILayout.MinMaxSlider

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public static function MinMaxSlider(ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float, params options: GUILayoutOption[]): void;
public static void MinMaxSlider(ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);
public static function MinMaxSlider(label: GUIContent, ref minValue: float, ref maxValue: float, minLimit: float, maxLimit: float, params options: GUILayoutOption[]): void;
public static void MinMaxSlider(GUIContent label, ref float minValue, ref float maxValue, float minLimit, float maxLimit, params GUILayoutOption[] options);

Parámetros

label Optional label in front of the slider.
value The value the slider shows. This determines the position of the draggable thumb.
minValue The lower value of the range the slider shows, passed by reference.
maxValue The upper value at the range the slider shows, passed by reference.
minLimit The limit at the left end of the slider.
maxLimit The limit at the right end of the slider.
options An optional list of layout options that specify extra layouting properties. Any values passed in here will override settings defined by the style.
See Also: GUILayout.Width, GUILayout.Height, GUILayout.MinWidth, GUILayout.MaxWidth, GUILayout.MinHeight, GUILayout.MaxHeight, GUILayout.ExpandWidth, GUILayout.ExpandHeight.

Descripción

Make a special slider the user can use to specify a range between a min and a max.


Moves the selected object randomly betweeen the interval.

	// Place the selected object randomly between the interval of the Min Max Slider
	// in the X,Y,Z coords
	
	class EditorGUILayoutMinMaxSlider extends EditorWindow {
	
		var minVal : float = -10;
		var minLimit : float = -20;
		var maxVal : float = 10;
		var maxLimit : float = 20;
		
		@MenuItem("Examples/Place Object Randomly")
		static function Init() {
			var window = GetWindow(EditorGUILayoutMinMaxSlider);
			window.Show();
		}
		
		function OnGUI() {
			EditorGUILayout.LabelField("Min Val:", minVal.ToString());
			EditorGUILayout.LabelField("Max Val:", maxVal.ToString());
			EditorGUILayout.MinMaxSlider(minVal, maxVal, minLimit, maxLimit);
			if(GUILayout.Button("Move!"))
				PlaceRandomly();
		}
		
		function PlaceRandomly() {
			if(Selection.activeTransform)
				Selection.activeTransform.position = 
					Vector3(Random.Range(minVal, maxVal),
							Random.Range(minVal, maxVal),
							Random.Range(minVal, maxVal));
			else 
				Debug.LogError("Select a GameObject to randomize its position.");
		}
	}