日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

技能CDDemo(点击鼠标左键实现技能界面旋转)

發布時間:2025/7/14 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 技能CDDemo(点击鼠标左键实现技能界面旋转) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

using UnityEngine; using System.Collections; using UnityEngine.UI;public class HealthController : MonoBehaviour {//當前對象是血條還是藍條public bool isHealth = false;//虛擬軸,橫軸,縱軸private float hor,ver;//血條的最大寬度private float healthMaxWidth = 470;//藍條的最大寬度private float powerMaxWidth = 425;//當前的虛擬軸private float currentAxis;//當前的最大寬度private float currentMaxWidth;//RectTransform組件private RectTransform rectTr;//速度public float speed = 100;//血條文本public Text healthText;//藍條文本public Text powerText;//血條藍條的最大值public float healthMaxValue = 1000f;public float powerMaxValue = 500f;//當前的條的最大值private float currentMaxValue;//當前修改的文本顯示框private Text currentText;void Start(){rectTr = GetComponent<RectTransform> ();}void Update(){hor = Input.GetAxis ("Horizontal");ver = Input.GetAxis ("Vertical");//如果是血條if (isHealth) {currentAxis = hor;currentMaxWidth = healthMaxWidth;currentText = healthText;currentMaxValue = healthMaxValue;}//如果是藍條else {currentAxis = ver;currentMaxWidth = powerMaxWidth;currentText = powerText;currentMaxValue = powerMaxValue;}//根據用戶的操作,計算當前條的寬度float newWidth = rectTr.sizeDelta.x +currentAxis * Time.deltaTime * speed;//限制寬度float realWidth = Mathf.Clamp (newWidth, 0, currentMaxWidth);//賦值到RectTransformrectTr.sizeDelta = new Vector2(realWidth,rectTr.sizeDelta.y);//計算當前數值float currentValue = (realWidth / currentMaxWidth) * currentMaxValue;//轉整數操作currentValue = Mathf.Round (currentValue);//將數值信息顯示到TextcurrentText.text = currentValue.ToString () + "/"+ currentMaxValue.ToString ();} }

技能組件界面 ?ImageType是Filled類型 數值是1與腳本里面初始值一致,腳本控制其數字從1-0減小調整白色畫布填充,達到有技能冷卻效果。

轉載于:https://www.cnblogs.com/VR-1024/p/6011699.html

《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

總結

以上是生活随笔為你收集整理的技能CDDemo(点击鼠标左键实现技能界面旋转)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。