Last active
April 23, 2018 21:01
-
-
Save listopad/06e4febd614e3ad57824dff585e94a1d to your computer and use it in GitHub Desktop.
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; | |
public class ObjectTrigger : MonoBehaviour | |
{ | |
// Тэг объекта, который мы ожидаем в триггере | |
public string objectTag; | |
// События, содержащие в себе вызовы функций | |
public UnityEvent OnObjectEnter, OnObjectStay, OnObjectExit; | |
private void OnTriggerEnter(Collider other) | |
{ | |
if (other.CompareTag(objectTag)) OnObjectEnter.Invoke(); | |
} | |
private void OnTriggerStay(Collider other) | |
{ | |
if (other.CompareTag(objectTag)) OnObjectStay.Invoke(); | |
} | |
private void OnTriggerExit(Collider other) | |
{ | |
if (other.CompareTag(objectTag)) OnObjectExit.Invoke(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment