mergemilitary/Assets/Scripts/UIs/CustomControl/HudHp.cs

27 lines
659 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HudHp : HUDBase
{
[SerializeField] Transform mTsfHp;
[SerializeField] Image mImgRedHp;
[SerializeField] Image mImgGreenHp;
private Image mImgAvailable;
public void InitHp(bool pIsRed, float pScale = 1)
{
mTsfHp.localScale = Vector3.one * pScale;
mImgAvailable = pIsRed ? mImgRedHp : mImgGreenHp;
mImgRedHp.gameObject.SetActive(pIsRed);
mImgGreenHp.gameObject.SetActive(!pIsRed);
}
public void RefreshHp(float pRatio)
{
mImgAvailable.fillAmount = pRatio;
}
}