Cute_demon_attacks/meng_yao/Assets/text.cs
2024-10-28 10:57:19 +08:00

38 lines
759 B
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
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();
}
}
}