首页 > 其他 > 详细

UGUI_冻结技能键盘点击触发

时间:2018-04-28 16:33:15      阅读:231      评论:0      收藏:0      [点我收藏+]

1.在某一张image图上添加Button组件,使其具有点击触发事件的功能;

2.outline组件

3.SkillItem脚本

 1 using System.Collections;
 2 using System.Collections.Generic;
 3 using UnityEngine;
 4 using UnityEngine.UI;
 5 
 6 public class SkillItem : MonoBehaviour {
 7     public float coldTime = 1;
 8     private Image filledImage;
 9     public KeyCode keycode;
10     private float timer = 0;
11     private bool isStartTimeer = false;
12     // Use this for initialization
13     void Start () {
14         filledImage = transform.Find("FilledImage").GetComponent<Image>();
15     }
16     
17     // Update is called once per frame
18     void Update () {
19         if (isStartTimeer)
20         {
21             timer += Time.deltaTime;
22         }
23         filledImage.fillAmount = (coldTime - timer) / coldTime;
24         if (timer >= coldTime)
25         {
26             filledImage.fillAmount = 0;
27             timer = 0;
28             isStartTimeer = false;
29         }
30 
31         if (Input.GetKeyDown(keycode))
32         {
33             isStartTimeer = true;
34         }
35     }
36     public void OnClick(){
37         isStartTimeer = true;
38     }
39 
40 }

Image类型为Filled;控制的参数为冻结图片中的组建Image中的fillAmount属性。

UGUI_冻结技能键盘点击触发

原文:https://www.cnblogs.com/NBOWeb/p/8968397.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!