NG_/Assets/Data Visualization Resources/Scripts/SliderRunTo1.cs
2024-12-13 19:40:05 +08:00

37 lines
483 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SliderRunTo1 : MonoBehaviour
{
public bool b=true;
public Slider slider;
public float speed=0.5f;
float time =0f;
void Start()
{
slider = GetComponent<Slider>();
}
void Update()
{
if(b)
{
time+=Time.deltaTime*speed;
slider.value = time;
if(time>1)
{
b = false;
time=0;
}
}
}
}