您的位置:首页 > 产品设计 > UI/UE

UGUI实现技能cd效果

2016-03-07 14:08 471 查看
、using UnityEngine;

using System.Collections;

//导入这个类  (自动导入插件)

using UnityEngine.UI;

public class SkillItem : MonoBehaviour {

// Use this for initialization
//冷却cd时间
public float cdTime = 2;
private bool isStartTimer;
private float time;
private Image filledImage;
public KeyCode myKey;
void Start () {
filledImage = transform.Find ("mask").GetComponent<Image> ();
}

// Update is called once per frame
void Update () {
if (Input.GetKeyDown (myKey))
{
isStartTimer = true;
}
if (isStartTimer)
{
time += Time.deltaTime;
filledImage.fillAmount
= (cdTime - time) / time;
if (time >= cdTime)
{
filledImage.fillAmount = 0;
time = 0;
isStartTimer = false;
}
}
}

public void onClick()
{
isStartTimer = true;
}
}

 mask这里设置为Filled
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: