Created
January 23, 2017 06:11
-
-
Save jmschrack/409f74fceecbd3afacd9b70d7d5fde71 to your computer and use it in GitHub Desktop.
For Unity3D, Wraps Collider methods as Delegates.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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