using DG.Tweening; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class EnergyUICtl : MonoBehaviour { /// /// 用于显示能量条进度 /// public Image energyScaleMask; /// /// 当前的能量条进度.10份进度. /// protected int currentProgress; // Start is called before the first frame update void Start() { currentProgress = 0; //this.SetEnergyProgress(0); } /// /// 获取进度条进度. /// /// public int GetCtlProgress() { return currentProgress; } /// /// 设置进度. /// /// public void SetCtlProcess(int pro) { if (pro == 10) pro = 0; energyScaleMask.rectTransform.DOKill(); this.SetEnergyProgress(pro,false); } /// /// 显示并更新能量条进度. /// /// public void SetEnergyProgress(int pro,bool ani = true) { if (pro == currentProgress) return; if( ani ) energyScaleMask.rectTransform.DOScaleY( pro / 10.0f, 0.3f ); else energyScaleMask.rectTransform.DOScaleY(pro / 10.0f, 0.0f); currentProgress = pro; } // Update is called once per frame void Update() { } }