Component.GetComponentIndex()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, InstantiateParameters)
Object.InstantiateAsync<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Namespace: UnityEngine.UI Assembly: UnityEngine.UI.dll Syntax[AddComponentMenu("UI/Slider", 34)]
[ExecuteAlways]
[RequireComponent(typeof(RectTransform))]
public class Slider : Selectable, IMoveHandler, IPointerDownHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler, ISelectHandler, IDeselectHandler, IDragHandler, IInitializePotentialDragHandler, IEventSystemHandler, ICanvasElement
Constructors Slider() Declaration Fields m_Value Declaration
[SerializeField]
protected float m_Value
Field Value Properties direction
The direction of the slider, from minimum to maximum value.
Declarationpublic Slider.Direction direction { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
public void Start()
{
//Changes the direction of the slider.
if (mainSlider.direction == Slider.Direction.BottomToTop)
{
mainSlider.direction = Slider.Direction.TopToBottom;
}
}
}
fillRect
Optional RectTransform to use as fill for the slider.
Declarationpublic RectTransform fillRect { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
//Reference to new "RectTransform"(Child of FillArea).
public RectTransform newFillRect;
//Deactivates the old FillRect and assigns a new one.
void Start()
{
mainSlider.fillRect.gameObject.SetActive(false);
mainSlider.fillRect = newFillRect;
}
}
handleRect
Optional RectTransform to use as a handle for the slider.
Declarationpublic RectTransform handleRect { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
//Reference to new "RectTransform" (Child of "Handle Slide Area").
public RectTransform handleHighlighted;
//Deactivates the old Handle, then assigns and enables the new one.
void Start()
{
mainSlider.handleRect.gameObject.SetActive(false);
mainSlider.handleRect = handleHighlighted;
mainSlider.handleRect.gameObject.SetActive(true);
}
}
maxValue
The maximum allowed value of the slider.
Declarationpublic float maxValue { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
void Start()
{
// Changes the max value of the slider to 20;
mainSlider.maxValue = 20;
}
}
minValue
The minimum allowed value of the slider.
Declarationpublic float minValue { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
void Start()
{
// Changes the minimum value of the slider to 10;
mainSlider.minValue = 10;
}
}
normalizedValue
The current value of the slider normalized into a value between 0 and 1.
Declarationpublic float normalizedValue { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
//Set to invoke when "OnValueChanged" method is called.
void CheckNormalisedValue()
{
//Displays the normalised value of the slider everytime the value changes.
Debug.Log(mainSlider.normalizedValue);
}
}
onValueChanged
Callback executed when the value of the slider is changed.
Declarationpublic Slider.SliderEvent onValueChanged { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
public void Start()
{
//Adds a listener to the main slider and invokes a method when the value changes.
mainSlider.onValueChanged.AddListener(delegate {ValueChangeCheck(); });
}
// Invoked when the value of the slider changes.
public void ValueChangeCheck()
{
Debug.Log(mainSlider.value);
}
}
value
The current value of the slider.
Declarationpublic virtual float value { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
//Invoked when a submit button is clicked.
public void SubmitSliderSetting()
{
//Displays the value of the slider in the console.
Debug.Log(mainSlider.value);
}
}
wholeNumbers
Should the value only be allowed to be whole numbers?
Declarationpublic bool wholeNumbers { get; set; }
Property Value Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
public void Start()
{
//sets the slider's value to accept whole numbers only.
mainSlider.wholeNumbers = true;
}
}
Methods FindSelectableOnDown()
See Selectable.FindSelectableOnDown
Declarationpublic override Selectable FindSelectableOnDown()
Returns Overrides FindSelectableOnLeft()
See Selectable.FindSelectableOnLeft
Declarationpublic override Selectable FindSelectableOnLeft()
Returns Overrides FindSelectableOnRight()
See Selectable.FindSelectableOnRight
Declarationpublic override Selectable FindSelectableOnRight()
Returns Overrides FindSelectableOnUp()
See Selectable.FindSelectableOnUp
Declarationpublic override Selectable FindSelectableOnUp()
Returns Overrides GraphicUpdateComplete()
See ICanvasElement.GraphicUpdateComplete
Declarationpublic virtual void GraphicUpdateComplete()
LayoutComplete()
See ICanvasElement.LayoutComplete
Declarationpublic virtual void LayoutComplete()
OnDidApplyAnimationProperties() Declaration
protected override void OnDidApplyAnimationProperties()
Overrides OnDisable() Declaration
protected override void OnDisable()
Overrides OnDrag(PointerEventData)
When dragging is occurring this will be called every time the cursor is moved.
Declarationpublic virtual void OnDrag(PointerEventData eventData)
Parameters OnEnable() Declaration
protected override void OnEnable()
Overrides OnInitializePotentialDrag(PointerEventData)
Called by a BaseInputModule when a drag has been found but before it is valid to begin the drag.
Declarationpublic virtual void OnInitializePotentialDrag(PointerEventData eventData)
Parameters OnMove(AxisEventData)
Determine in which of the 4 move directions the next selectable object should be found.
Declarationpublic override void OnMove(AxisEventData eventData)
Parameters Overrides Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.
public class ExampleClass : MonoBehaviour, IMoveHandler
{
//When the focus moves to another selectable object, Invoke this Method.
public void OnMove(AxisEventData eventData)
{
//Assigns the move direction and the raw input vector representing the direction from the event data.
MoveDirection moveDir = eventData.moveDir;
Vector2 moveVector = eventData.moveVector;
//Displays the information in the console
Debug.Log(moveDir + ", " + moveVector);
}
}
OnPointerDown(PointerEventData)
Evaluate current state and transition to pressed state.
Declarationpublic override void OnPointerDown(PointerEventData eventData)
Parameters Overrides Examples
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;// Required when using Event data.
public class ExampleClass : MonoBehaviour, IPointerDownHandler// required interface when using the OnPointerDown method.
{
//Do this when the mouse is clicked over the selectable object this script is attached to.
public void OnPointerDown(PointerEventData eventData)
{
Debug.Log(this.gameObject.name + " Was Clicked.");
}
}
OnRectTransformDimensionsChange()
This callback is called when the dimensions of an associated RectTransform change. It is always called before Awake, OnEnable, or Start. The call is also made to all child RectTransforms, regardless of whether their dimensions change (which depends on how they are anchored).
Declarationprotected override void OnRectTransformDimensionsChange()
Overrides OnValidate() Declaration
protected override void OnValidate()
Overrides Rebuild(CanvasUpdate)
Rebuild the element for the given stage.
Declarationpublic virtual void Rebuild(CanvasUpdate executing)
Parameters Type Name Description CanvasUpdate executing
The current CanvasUpdate stage being rebuild.
Set(float, bool)Set the value of the slider.
Declarationprotected virtual void Set(float input, bool sendCallback = true)
Parameters Type Name Description float input
The new value for the slider.
bool sendCallbackIf the OnValueChanged callback should be invoked.
SetDirection(Direction, bool)Sets the direction of this slider, optionally changing the layout as well.
Declarationpublic void SetDirection(Slider.Direction direction, bool includeRectLayouts)
Parameters Type Name Description Slider.Direction direction
The direction of the slider
bool includeRectLayoutsShould the layout be flipped together with the slider direction
Examplesusing UnityEngine;
using System.Collections;
using UnityEngine.UI; // Required when Using UI elements.
public class Example : MonoBehaviour
{
public Slider mainSlider;
public void Start()
{
mainSlider.SetDirection(Slider.Direction.LeftToRight, false);
}
}
SetValueWithoutNotify(float)
Set the value of the slider without invoking onValueChanged callback.
Declarationpublic virtual void SetValueWithoutNotify(float input)
Parameters Type Name Description float input
The new value for the slider.
Update()Update the rect based on the delayed update visuals. Got around issue of calling sendMessage from onValidate.
Declarationprotected virtual void Update()
Implements
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4