Unity Collision Helper

Detecting collisions in Unity is done by adding a Collider to an object, and then a Monobehaviour that has some sort of Trigger/Collision handler (e.g. OnCollisionEnter). Although this works fine, the point where you are able to detect the collision is not always the point where you would like to handle the collision. There are different solutions to this, some more or less general than others. For example we could create a global EventBus/Queue idea that decouples the collider and the handler.

Basically what we would like to have is some sort of way to say:

collider.OnTriggerEnter += MyOnTriggerEnterCallback

(or something similar for OnCollisionEnter). The sample below demonstrates this basic principle using a simple CollisionHelper script.

Download: Collision Helper (24)

As always use at your own risk ;).