zoukankan      html  css  js  c++  java
  • UGUI_冻结技能键盘点击触发

    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属性。

  • 相关阅读:
    APIO2007 动物园
    SCOI2010 股票交易
    USACO13NOV No Change G
    洛谷 P3694 邦邦的大合唱站队
    洛谷 P6196 3月月赛 ERR1 代价
    洛谷月赛 ERR1 代价
    Splay 学习笔记
    HNOI2009 梦幻布丁
    乘法逆元
    【洛谷】【二分答案+最短路】P1462 通往奥格瑞玛的道路
  • 原文地址:https://www.cnblogs.com/NBOWeb/p/8968397.html
Copyright © 2011-2022 走看看