I am creating an editor extension that includes an API for developers to use. It also includes events like (for example) "OnHealthChanged."
The problem is that events I have stumbled upon would require a user to subscribe to them, which is not what I actually want. I want developers simply type in the event handler in their script, and it would just work.
For example, I want a programmer to write a function "OnHealthChanged" in their own script. When the health changes, their code runs.
void OnHealthChanged()
{
//code that is going to run when health changes
}
Any idea where can I look?
I want to create something like "OnCollisionEnter()" event in Unity, which runs code every time a game object collides with another game object.
Hope it makes sense.