In my current Unity project I implemented Event System in most simple way. All events are stored in one class, are public and can be invoked or subscribed to from any other class.
public class EventManager : MonoBehaviour
{
public event Action<Player> PlayerDied;
public void InvokePlayerDied(Player player)
{
PlayerDied?.Invoke(player);
}
public event Action<int> HealthChanged;
public void InvokeHealthChanged(int newValue)
{
HealthChanged?.Invoke(newValue);
}
// etc.
}
It is very easy to use, because all other classes need reference only to EventManager. But since events are public and can be called from anywhere, I feel like it is bad architecture.
(Of course, I do unsubscribe from events in OnDisable)
So, before my project scales, I want to know is this really a bad design and what issues can it cause?
If it is bad, then what would be the best alternative?