Added lots of examples for editor customization

This commit is contained in:
2026-06-23 18:33:11 +02:00
parent bbb7062c5b
commit 0512201ce0
58 changed files with 920 additions and 116 deletions
@@ -0,0 +1,52 @@
using Data;
using Events;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace UI
{
public class HealthBar : MonoBehaviour
{
[Header("Events")]
[SerializeField] private EventBroker eventBroker;
[Header("Values")]
[SerializeField] private FloatValue maxHealth;
[SerializeField] private FloatValue currentHealth;
[Header("References")]
[SerializeField] private Image fillingImage;
[SerializeField] private TextMeshProUGUI deadMessageText;
private void Awake()
{
fillingImage.type = Image.Type.Filled;
fillingImage.fillMethod = Image.FillMethod.Horizontal;
fillingImage.fillOrigin = 0;
deadMessageText.gameObject.SetActive(false);
}
private void OnEnable()
{
eventBroker.PlayerDied += OnPlayerDied;
}
private void OnDisable()
{
eventBroker.PlayerDied -= OnPlayerDied;
}
private void Update()
{
fillingImage.fillAmount = currentHealth.Value / maxHealth.Value;
}
private void OnPlayerDied()
{
fillingImage.fillAmount = 0.0f;
currentHealth.Value = 0.0f;
deadMessageText.gameObject.SetActive(true);
}
}
}