- Home /
UnityEngine.UI is not showing up?
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;
}
}
Comment
Answer by WASD098 · Dec 19, 2021 at 11:04 AM
Actually using a slider instead fixes the issue for anyone with the same problem although a red line does still appear under the using UnityEngine.UI in vsc.