2020-03-01 20:26:06 -05:00
using UnityEngine ;
2019-10-15 19:43:51 -04:00
2020-03-01 20:26:06 -05:00
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")]
[AddComponentMenu("Unity Atoms/Hooks/On Trigger Hook")]
public sealed class OnTriggerHook : ColliderHook
{
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerEnter`
/// </summary>
[SerializeField]
private bool _triggerOnEnter = default ( bool ) ;
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerExit`
/// </summary>
[SerializeField]
private bool _triggerOnExit = default ( bool ) ;
/// <summary>
/// Set to true if Event should be triggered on `OnTriggerStay`
/// </summary>
[SerializeField]
private bool _triggerOnStay = default ( bool ) ;
2019-10-15 19:43:51 -04:00
2020-03-01 20:26:06 -05:00
private void OnTriggerEnter ( Collider other )
{
if ( _triggerOnEnter ) OnHook ( other ) ;
}
2019-10-15 19:43:51 -04:00
2020-03-01 20:26:06 -05:00
private void OnTriggerExit ( Collider other )
{
if ( _triggerOnExit ) OnHook ( other ) ;
}
2019-10-15 19:43:51 -04:00
2020-03-01 20:26:06 -05:00
private void OnTriggerStay ( Collider other )
{
if ( _triggerOnStay ) OnHook ( other ) ;
}
}
}