Callback executed when the value of the slider is changed.
#pragma strict // Required when Using UI elements. public class Example { public var mainSlider; public function Start() { //Adds a listener to the main slider and invokes a method when the value changes. mainSlider.onValueChanged.AddListener(function() { ValueChangeCheck(); }); } // Invoked when the value of the slider changes. public function ValueChangeCheck() { Debug.Log(mainSlider.value); } }
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); } }