Version: 2017.2

Slider.onValueChanged

切换到手册
public UI.Slider.SliderEvent onValueChanged ;

描述

当滑动条的值发生更改时执行的回调。

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