If you're wondering how to make custom "On" statements like OnTriggerEnter they are called messages, and this is the way of doing it in unity atleast https://docs.unity3d.com/ScriptReference/Component.SendMessage.html