HealthDisplayText.cs 572 B

12345678910111213141516171819202122232425
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class HealthDisplayText : MonoBehaviour {
  6. Nexus target;
  7. public Text MoneyText;//金钱UI
  8. public Text HpText;//血量UI
  9. void Start()
  10. {
  11. target = Nexus.CurrentInstance;
  12. }
  13. void OnGUI()
  14. {
  15. //刷新金钱的显示
  16. MoneyText.text ="Money: " + target.CurrentMana + "/" + target.maxMana;
  17. //刷新血量显示
  18. HpText.text = "HP: " + target.CurrentHealth + "/" + target.maxHealth;
  19. }
  20. }