using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PointsBar : MonoBehaviour { //导入血条和韧性条 public Image points; public Image effect; float ratio; public float recoverRate = 0.4f; public float damageRate = 0.3f; void Update() { if(points.fillAmount < ratio) { if(points.fillAmount + recoverRate < ratio) points.fillAmount += recoverRate * Time.deltaTime; else points.fillAmount = ratio; } else points.fillAmount = ratio; if(effect.fillAmount > points.fillAmount) { effect.fillAmount -= damageRate * Time.deltaTime; } else effect.fillAmount = points.fillAmount; } public void ChangeUI(float newRatio) { ratio = newRatio; } }