2019-10-16 01:43:51 +02:00
using UnityEngine ;
namespace UnityAtoms.MonoHooks
{
/// <summary>
/// Mono Hook for [`OnTriggerEnter`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerEnter.html), [`OnTriggerExit`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerExit.html) and [`OnTriggerStay`](https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnTriggerStay.html)
/// </summary>
[EditorIcon("atom-icon-delicate")]
2019-11-13 08:59:39 +01:00
[AddComponentMenu("Unity Atoms/Hooks/On Trigger Hook")]
2019-10-16 01:43:51 +02:00
public sealed class OnTriggerStayHook : ColliderHook
{
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerEnter`
/// </summary>
[SerializeField]
2019-10-20 21:16:07 +02:00
private bool _triggerOnEnter = default ( bool ) ;
2019-10-16 01:43:51 +02:00
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerExit`
/// </summary>
[SerializeField]
2019-10-20 21:16:07 +02:00
private bool _triggerOnExit = default ( bool ) ;
2019-10-16 01:43:51 +02:00
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerStay`
/// </summary>
[SerializeField]
2019-10-20 21:16:07 +02:00
private bool _triggerOnStay = default ( bool ) ;
2019-10-16 01:43:51 +02:00
private void OnTriggerEnter ( Collider other )
{
if ( _triggerOnEnter ) OnHook ( other ) ;
}
private void OnTriggerExit ( Collider other )
{
if ( _triggerOnExit ) OnHook ( other ) ;
}
private void OnTriggerStay ( Collider other )
{
if ( _triggerOnStay ) OnHook ( other ) ;
}
}
}