Unity 技能冷却条
程序员文章站
2022-04-03 08:38:30
...
using UnityEngine;
using UnityEngine.UI;
///<summary>
///技能冷却条
///</summary>
public class SkillItem : MonoBehaviour
{
public float coldTime = 2f;
private float timer = 0f; //
private Image filledImage;
private bool isStartTimer;
// Start is called before the first frame update
void Start()
{
filledImage = transform.Find("FilledSkill").GetComponent<Image>();
}
// Update is called once per frame
void Update()
{
if(isStartTimer){
timer += Time.deltaTime;
filledImage.fillAmount = (coldTime-timer)/coldTime;
}
if(timer >= coldTime){
filledImage.fillAmount = 0;
timer = 0;
isStartTimer = false;
}
}
public void OoClick(){
isStartTimer = true;
}
}
上一篇: Java发送http请求发送json对象
下一篇: Xcode下载模拟器太慢?