技能冷却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;
}
}
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;
}
}
相关文章推荐
- Kinect结合Unity3D引擎开发体感游戏(一)
- Unity3D中脚本的执行顺序和编译顺序
- Unity3D动态对象优化代码分享
- unity3d发布apk在android虚拟机中运行的详细步骤(unity3d导出android apk)
- Unity3D游戏引擎实现在Android中打开WebView的实例
- unity3d调用手机或电脑摄像头
- 分享一个开源的网络游戏服务器架构—HouHai
- Unity3D插件详细评测及教学下载
- Unity3D上路_01-2D太空射击游戏
- Unity3D上路_02-第一视角射击游戏
- Unity3D上路_03-塔防游戏
- Unity3D上路_04-基础资源介绍
- Unity3D上路_05-网络相关
- Unity3d TransformPoint 函数研究
- Unity3d 动态加载fbx模型文件
- unity3d地形系统总结