Skip to content

Instantly share code, notes, and snippets.

@listopad
Last active April 23, 2018 21:01
Show Gist options
  • Save listopad/06e4febd614e3ad57824dff585e94a1d to your computer and use it in GitHub Desktop.
Save listopad/06e4febd614e3ad57824dff585e94a1d to your computer and use it in GitHub Desktop.
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