HKI Core
EnterAndExitTrigger.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using UnityEngine.Events;
3 
4 namespace HKI.Core.Triggers
5 {
9  public class EnterAndExitTrigger : MonoBehaviour
10  {
11  // Public Variables
12  [Header("Callbacks on enter:")]
13  [SerializeField] UnityEvent OnEnter = new UnityEvent();
14 
15  [Header("Callbacks on exit:")]
16  [SerializeField] UnityEvent OnExit = new UnityEvent();
17 
18  // Trigger function
19  void OnTriggerEnter(Collider collider)
20  {
21  OnEnter.Invoke();
22  }
23 
24  void OnTriggerExit(Collider collider)
25  {
26  OnExit.Invoke();
27  }
28  }
29 }
This trigger will invoke added functions on enter and exit.