Add unity event
This commit is contained in:
parent
a2ad4a99d2
commit
54a2575703
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class TriggerZone : MonoBehaviour
|
||||
{
|
||||
@ -8,11 +9,15 @@ public class TriggerZone : MonoBehaviour
|
||||
private Triggerable linkedObj;
|
||||
[SerializeField]
|
||||
private bool onEnter = true, onStay = false, OnExit = false;
|
||||
public UnityEvent enterEvent;
|
||||
public UnityEvent stayEvent;
|
||||
public UnityEvent exitEvent;
|
||||
// Start is called before the first frame update
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
if(!onEnter)return;
|
||||
if(other.gameObject.tag.Equals("Player")){
|
||||
linkedObj.TriggerEvent();
|
||||
enterEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,6 +25,7 @@ public class TriggerZone : MonoBehaviour
|
||||
if(!onStay)return;
|
||||
if(other.gameObject.tag.Equals("Player")){
|
||||
linkedObj.TriggerEvent();
|
||||
stayEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +33,7 @@ public class TriggerZone : MonoBehaviour
|
||||
if(!OnExit)return;
|
||||
if(other.gameObject.tag.Equals("Player")){
|
||||
linkedObj.TriggerEvent();
|
||||
exitEvent?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user