using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class text : MonoBehaviour { public event Action TimeEnd; private float tim=0f; public Image img; bool is_time_ing = true; float time_max = 0; public void upadte_time(float times ) { tim = times; time_max = times; is_time_ing = false; } // Update is called once per frame void Update() { if (tim > 0) { tim -= Time.deltaTime; img.fillAmount = tim/ time_max; } else if (!is_time_ing) { is_time_ing = true; TimeEnd.Invoke(); } } }