UI中各种显示数值占比的矩形

master
SweetMe1ody 5 years ago
parent 08f5eca756
commit 71e4842ff9

@ -0,0 +1,38 @@
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;
}
}
Loading…
Cancel
Save