Skip to content

Instantly share code, notes, and snippets.

@jmschrack
Created January 23, 2017 06:11
Show Gist options
  • Save jmschrack/409f74fceecbd3afacd9b70d7d5fde71 to your computer and use it in GitHub Desktop.
Save jmschrack/409f74fceecbd3afacd9b70d7d5fde71 to your computer and use it in GitHub Desktop.
For Unity3D, Wraps Collider methods as Delegates.
using UnityEngine;
public class ColliderCallback : MonoBehaviour {
public delegate void Enter(Collision other);
public Enter enter;
public delegate void Exit(Collision other);
public Exit exit;
public delegate void Stay(Collision other);
public Stay stay;
void Awake(){
enter+=DoNothing;
exit+=DoNothing;
stay+=DoNothing;
}
void OnCollisionEnter(Collision other){
enter(other);
}
void OnCollisionExit(Collision other){
exit(other);
}
void OnCollisionStay(Collision other){
stay(other);
}
void DoNothing(Collision other){}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment