23 lines
628 B
C#
23 lines
628 B
C#
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HealthBar : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image img_fill;
|
|
[SerializeField] private Image img_fillWhite;
|
|
[SerializeField] private float imgWhiteFillSpeed = 1f;
|
|
|
|
private float targetFillAmount;
|
|
|
|
private void Update()
|
|
{
|
|
img_fillWhite.fillAmount = Mathf.Lerp(img_fillWhite.fillAmount, targetFillAmount, Time.deltaTime * imgWhiteFillSpeed);
|
|
}
|
|
|
|
public void SetFillingAmount(float fillingAmount)
|
|
{
|
|
targetFillAmount = fillingAmount;
|
|
img_fill.fillAmount = targetFillAmount;
|
|
}
|
|
} |