|
|
|
|
|
|
using NaughtyAttributes; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
|
|
|
|
public int EnterMaxCount = 0; |
|
|
|
public int ExitMaxCount = 0; |
|
|
|
|
|
|
|
private int m_RemainingEnterCount; |
|
|
|
private int m_RemainingExitCount; |
|
|
|
|
|
|
|
[ReorderableList] |
|
|
|
public Callable[] onTriggerEnter; |
|
|
|
|
|
|
|
|
|
|
public bool OnlyInteractWithTag = true; |
|
|
|
public string Tag = "Player"; |
|
|
|
|
|
|
|
void Start() |
|
|
|
{ |
|
|
|
m_RemainingEnterCount = EnterMaxCount; |
|
|
|
m_RemainingExitCount = ExitMaxCount; |
|
|
|
} |
|
|
|
|
|
|
|
if (EnterMaxCount > 0) |
|
|
|
{ |
|
|
|
if (m_RemainingEnterCount == 0) return; |
|
|
|
m_RemainingEnterCount--; |
|
|
|
} |
|
|
|
if (OnlyInteractWithTag && other.tag == Tag ) |
|
|
|
{ |
|
|
|
Callable.Call(onTriggerEnter, other.gameObject); |
|
|
|
|
|
|
|
|
|
|
private void OnTriggerExit(Collider other) |
|
|
|
{ |
|
|
|
if (ExitMaxCount > 0) |
|
|
|
{ |
|
|
|
if (m_RemainingExitCount == 0) return; |
|
|
|
m_RemainingExitCount--; |
|
|
|
} |
|
|
|
if (OnlyInteractWithTag && other.tag == Tag ) |
|
|
|
{ |
|
|
|
Callable.Call(onTriggerExit, other.gameObject); |
|
|
|