Unity - Scripting API: UI.Slider.onValueChanged (2024)

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); }}

Unity - Scripting API: UI.Slider.onValueChanged (2024)
Top Articles
Latest Posts
Article information

Author: Ray Christiansen

Last Updated:

Views: 5671

Rating: 4.9 / 5 (69 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Ray Christiansen

Birthday: 1998-05-04

Address: Apt. 814 34339 Sauer Islands, Hirtheville, GA 02446-8771

Phone: +337636892828

Job: Lead Hospitality Designer

Hobby: Urban exploration, Tai chi, Lockpicking, Fashion, Gunsmithing, Pottery, Geocaching

Introduction: My name is Ray Christiansen, I am a fair, good, cute, gentle, vast, glamorous, excited person who loves writing and wants to share my knowledge and understanding with you.