I have a script that needs to access Image.fillAmount but this is only in UnityEngine.UI which doesn't work even though I have Unity UI package installed.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class BattleHud : MonoBehaviour
{
public TextMeshProUGUI unitName;
public TextMeshProUGUI level;
public Image healthBar;
void Awake()
{
}
public void SetHUD(Unit unit)
{
unitName.text = unit.unitName;
level.text = "Lvl. "+unit.level.ToString();
healthBar.fillAmount = unit.curHealth/unit.maxHealth;
}
public void SetHP(Unit unit)
{
healthBar.fillAmount = unit.curHealth/unit.maxHealth;
}
}
↧