To deal damage call the Damage(int amount) function. When damage is taken all events in the OnDamage UnityEvent will be invoked and if health is <= 0 then OnDeath will be invoked aswell.
Important
OnDeath is invoked AFTER OnDamage and not instead of.
Implimentation in Health.cs/Damage(int amount)
To heal call the Heal(int amount) function. This function will also invoke all events in the OnHealth UnityEvent.
Implimentation in Health.cs/Heal(int amount)
If you would like to subscribe to the events through scripts you can call SubscribeTo...(UnityAction action) followed by the name of the corresponding Unity Event. Ex: SubscribeToOnDeath(UnityAction action). To unsubscribe is the same process but instead you call UnsubscribeFrom...(UnityAction action) with the UnityAction you wish to remove from the Event.
A Health script is required to be on the same object as the HealthDisplayer.
If one is not already on it then one will be created for you due to the effect of [RequireComponent(typeof(Health))]\
A reference to a Slider is required
A TextMeshProUGUI is required. While displaying as a number there are several formats to chose from which go as follows.
| Type | Result |
|---|---|
| Out Of | 50/100 |
| Percentage | 50% |
| Raw Number | 50 |
| Custom | This splits the max and current health values into two separate TextMeshProUGUI objects allowing for the user to manipulate placement and text styles however they please. |
https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/api/TMPro.TextMeshProUGUI.html
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/UIElements.Slider.html
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/Events.UnityAction.html
https://docs.unity3d.com/6000.2/Documentation/ScriptReference/RequireComponent.html
