zoukankan      html  css  js  c++  java
  • unity 利用ugui 制作技能冷却效果

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    
    public class SkillItem : MonoBehaviour {
    
    	//冷却时间
    	public float coldTime = 2.0f;
    
    	//定时器
    	private float timer = 0f;
    
    	//前面的一张填充图片
    	private Image filedImage;
    
    	//是否开始技能冷却
    	private bool isStartTimer = false;
    	// Use this for initialization
    	void Start () {
    		filedImage = transform.Find ("FilledImage").GetComponent<Image> ();
    	}
    	
    	// Update is called once per frame
    	void Update () {
    		//已经开始冷却
    		if (isStartTimer) {
    			timer += Time.deltaTime;
    
    			//计算fillAmount
    			filedImage.fillAmount =	(coldTime - timer) / coldTime;
    			if (timer >= coldTime) {
    
    				//停止定时器
    				filedImage.fillAmount = 0;
    				timer = 0;
    				isStartTimer = false;
    			}
    		}
    	}
    
    	public void OnClick()
    	{
    		isStartTimer = true;
    	}
    }
    
    
  • 相关阅读:
    如何优雅地删除 Linux 中的垃圾文件
    session:
    cookie:
    多对多表结构设计:
    接口测试:
    oracle基本笔记整理
    oracle基本笔记整理
    oracle基本笔记整理
    2016年寒假心得
    2016年寒假心得
  • 原文地址:https://www.cnblogs.com/yufenghou/p/6258073.html
Copyright © 2011-2022 走看看