Cute_demon_attacks/meng_yao/Assets/text.cs

38 lines
759 B
C#
Raw Normal View History

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