原文博客https://blog.csdn.net/dengshunhao/article/details/83503833
本文代码,思路来自《千喜》
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GetSliderStopEvent : MonoBehaviour {
public float SliderAllTime = 0.5f;
public float SliderCurTime = 0;
public bool isUpadateBright = false;
float LatSliderValue; //上一帧的Slider数值
[SerializeField] Slider slider;
public void sendBrightness(float value) {
isUpadateBright = true;
}
private void Update()
{
if (isUpadateBright)
{
if (LatSliderValue.Equals(slider.value))
{
SliderCurTime += Time.deltaTime;
if (SliderCurTime >= SliderAllTime)
{
SliderCurTime = 0;
isUpadateBright = false;
Debug.Log("不滑动*****************");
}
}
else {
SliderCurTime = 0;
LatSliderValue = slider.value;
Debug.Log("Slider正在滑动中**********");
}
}
}
}