using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class EnergyUI : MonoBehaviour { public Text text; public BattleController battleController; private int renderedEnergy = -1; private int renderedMaxEnergy = -1; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (this.renderedEnergy != battleController.GetEnergy() || this.renderedMaxEnergy != battleController.GetMaxEnergy()) { string currentEnergyString = "" + battleController.GetEnergy(); if (battleController.GetEnergy() == 0) { currentEnergyString = "" + currentEnergyString + ""; } text.text = "Energy: " + currentEnergyString + " / " + battleController.GetMaxEnergy(); this.renderedEnergy = battleController.GetEnergy(); this.renderedMaxEnergy = battleController.GetMaxEnergy(); } } }