Unity制作游戏中技能使用后转CD的场景
来源:互联网 发布:虚拟机网络连接模式 编辑:程序博客网 时间:2024/06/07 17:35
因为我们需要用鼠标点击图片让它重新转CD,所以我们需要创建一个Button,然后把Button的子物体Test删除掉,加一个Image为他的子物体。
然后我们把图片(这里图片必须是 Sprite (2D and UI)格式的)拖入到Button 的Source Image中,同时拖入到Image的Source Image中,然后在Image中他调整它的颜色,并且改变它的Image Type为Filled,这里颜色自己调整,设置如下图
为了达到点击图片转CD的效果写了脚本:
using UnityEngine;using System.Collections;using UnityEngine.UI;public class CDHyp : MonoBehaviour { //剩余时间 public float leftTime; //CD转完的总时间 public float totalTime; private Image effectImage; private Button cdButton; // Use this for initialization void Start () { effectImage = transform.FindChild("Image").GetComponent<Image>(); // effectImage = GetComponent<Image>(); leftTime = totalTime; cdButton = transform.GetComponent<Button>(); cdButton.interactable = false; } // Update is called once per frame void Update () { leftTime -= Time.deltaTime; if (effectImage.fillAmount>0) { effectImage.fillAmount = leftTime / totalTime; } else { effectImage.fillAmount = 0; cdButton.interactable = true; } } public void FireSkillHyp() { Debug.Log("技能使用"); leftTime = totalTime; cdButton.interactable = false; effectImage.fillAmount = 1; }}
另外,这里我们还需要把脚本中FireSkillHyp这个事件添加到Button中
阅读全文
0 0
- Unity制作游戏中技能使用后转CD的场景
- AS3中技能或物品CD时间案例(转)
- 游戏中技能冷却效果
- Unity制作游戏中的场景
- 老板喜欢的10中技能
- Unity游戏开发使用Assetbundle加载场景的原理
- Unity游戏开发使用Assetbundle加载场景的原理
- Unity游戏开发使用Assetbundle加载场景的原理
- Unity游戏开发使用Assetbundle加载场景的实战
- [Unity3d]如何制作unity能使用的RGBA材质贴图
- 使用Unity制作俄罗斯方块游戏
- MMORPG中技能战斗系统的技术分享
- MMORPG中技能战斗系统的技术分享
- unity打靶游戏的制作
- 分享使用Unity制作游戏关卡的教程(1)
- 分享使用Unity制作游戏关卡的教程(2)
- 开发者分享使用Unity制作2D游戏的技巧
- 【Unity】场景异步加载的进度条制作
- DNS | Array | Object | Map | Set | iterable ---[廖雪峰老师js教程笔记]
- 637. Average of Levels in Binary Tree
- Block的内部实现原理
- java的持久化技术选型
- win7 批处理文件默认以管理员身份运行及清除IE缓存脚本
- Unity制作游戏中技能使用后转CD的场景
- 将一个本地项目提交到git
- 数据结构 — 希尔排序
- c#一些概念
- svn的cleanup失败的解决方案
- 迷宫找最短路径 深度优先—C
- 使用cookie+工具类实现的 记录显示 用户【浏览商品记录】
- echo等追加到文件末尾
- 数据库的垂直切分和水平切分