using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SkillCd : MonoBehaviour
{
public Image image, cdimg;
float cd = 0;
bool istrue = false;
public Text text;
// Start is called before the first frame update
void Start()
{
image.GetComponent<Button>().onClick.AddListener(() =>
{
if (ispress)
{
cd = 3;
text.gameObject.SetActive(true);
ispress = false;
istrue = true;
cdimg.GetComponent<Image>().fillAmount =1;
}
});
}
bool ispress = true;
// Update is called once per frame
void Update()
{
if (istrue)
{
cd -= Time.deltaTime;
text.text = cd.ToString("0.0");
cdimg.GetComponent<Image>().fillAmount = cd / 3;
if (cd<=0)
{
text.gameObject.SetActive(false);
ispress = true;
istrue=false;
cd = 0;
}
}
}
}