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

技能冷却UGUI5.1

2015-09-14 10:09 453 查看
using UnityEngine;

using System.Collections;

using UnityEngine.UI;

public class SkillItem : MonoBehaviour

{

    public float coldTime = 2;

    public KeyCode keycode;

    private float timer = 0;

    private Image filledImage;

    private bool isStartTimer = false;
// Use this for initialization
void Start ()
{
   filledImage = transform.Find("FilledImage").GetComponent<Image>();
   Toggle toggle;
   ToggleGroup group;
}

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

    public void OnClick()

    {

        isStartTimer = true;

    }

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