Created
January 23, 2017 06:09
-
-
Save jmschrack/2f93e298ad8268a96afb8130fc5796e2 to your computer and use it in GitHub Desktop.
For Unity3D, converts Trigger methods into 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; | |
using System.Collections; | |
public class TriggerCallback : MonoBehaviour { | |
public delegate void Enter(Collider other); | |
public Enter enter; | |
public delegate void Exit(Collider other); | |
public Exit exit; | |
public delegate void Stay(Collider other); | |
public Stay stay; | |
void Awake(){ | |
enter+=DoNothing; | |
exit+=DoNothing; | |
stay+=DoNothing; | |
} | |
void DoNothing(Collider other){} | |
void OnTriggerEnter(Collider other){ | |
enter(other); | |
} | |
void OnTriggerExit(Collider other){ | |
exit(other); | |
} | |
void OnTriggerStay(Collider other){ | |
stay(other); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment