Last active
January 23, 2017 07:21
-
-
Save jmschrack/ad165ecd350b4c0eaf20e56b6464900a to your computer and use it in GitHub Desktop.
For Unity3D Triggers, lets you attach UnityEvents to Trigger events
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 UnityEngine.Events; | |
using System.Collections; | |
public class TriggerEvent : MonoBehaviour { | |
public bool EnterOnce; | |
bool enterFire; | |
public UnityEvent EnterEvent; | |
public bool StayOnce; | |
bool stayFire; | |
public UnityEvent StayEvent; | |
public bool ExitOnce; | |
bool exitFire; | |
public UnityEvent ExitEvent; | |
void OnTriggerEnter(Collider other){ | |
if(!EnterOnce||(EnterOnce&&!enterFire)){ | |
EnterEvent.Invoke(); | |
} | |
} | |
void OnTriggerStay(Collider other){ | |
if(!StayOnce||(StayOnce&&!stayFire)){ | |
StayEvent.Invoke(); | |
} | |
} | |
void OnTriggerExit(Collider other){ | |
if(!ExitOnce||(ExitOnce&&!exitFire)){ | |
ExitEvent.Invoke(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment