Check OnCollisionEnter on other GameObject

Would like to know is there anyway for detecting GameObject OnCollisionEnter from script attached to other game objects? For example, I have a manager class that runs all the game logic (checking collision etc.) as such?

public class Manager : MonoBehaviour {
	public GameObject Button;
	public GameObject Button2;

 	void Start(){
 		Button.OnCollisionEnter += OnButtonCollision;
 		Button2.OnCollisionEnter += OnButton2Collision;
 	}

 	void OnButtonCollision(Collision hit){
 		Debug.Log("Button collided");
 	}

 	void OnButton2Collision(Collision hit){
 		Debug.Log("Button2 collided");
 	} 	
}

Above code won’t work, right now I am doing it by attaching different script to the button and sendmessage between. Looking for more centralized collision checking. Any solutions?

Sure you can just write a script that exposes them as events and then use that with registration to attach whatever you like.

[RequireComponent(typeof(RigidBody))]
public class CollisionEvents
{
     public event Action<CollisionEvents, Collision> onCollisionEnter = delegate {};
     public event Action<CollisionEvents, Collision> onCollisionExit = delegate {};
     public event Action<CollisionEvents, Collision> onCollisionStay = delegate {};

     public static event Action<CollisionEvents, Collision> onAllCollisionEnter = delegate {};
     public static event Action<CollisionEvents, Collision> onAllCollisionExit = delegate {};
     public static event Action<CollisionEvents, Collision> onAllCollisionStay = delegate {};
     //OnTriggerXXX etc

     void OnCollisionEnter(Collision collision)
     {
         onCollisionEnter(this, collision);
         onAllCollisionEnter(this, collision);
     }

     //Etcetera


}

Then you can either wire up an all collision event or use GetComponent to find a specific item

    GameObject.Find("SomeObject").GetComponent<CollisionEvents>().onCollisionEnter += SomeMethod;

Or

    CollisionEvents.onAllCollisionEnter += SomeOtherMethod;

Remember to unwire events after the holder is destroyed or you will leak memory.