// UltEvents // Copyright 2020 Kybernetik //
using UnityEngine;
namespace UltEvents
{
///
/// An event that takes a single parameter.
///
[System.Serializable]
public sealed class TriggerEvent2D : UltEvent { }
/************************************************************************************************************************/
///
/// Holds s which are called by various 2D trigger events:
/// , , and .
///
[AddComponentMenu(UltEventUtils.ComponentMenuPrefix + "Trigger Events 2D")]
[HelpURL(UltEventUtils.APIDocumentationURL + "/TriggerEvents2D")]
[DisallowMultipleComponent]
[RequireComponent(typeof(Collider2D))]
public class TriggerEvents2D : MonoBehaviour
{
/************************************************************************************************************************/
[SerializeField]
private TriggerEvent2D _TriggerEnterEvent;
/// Invoked by .
public TriggerEvent2D TriggerEnterEvent
{
get
{
if (_TriggerEnterEvent == null)
_TriggerEnterEvent = new TriggerEvent2D();
return _TriggerEnterEvent;
}
set { _TriggerEnterEvent = value; }
}
/// Invokes .
public virtual void OnTriggerEnter2D(Collider2D collider)
{
if (_TriggerEnterEvent != null)
_TriggerEnterEvent.Invoke(collider);
}
/************************************************************************************************************************/
[SerializeField]
private TriggerEvent2D _TriggerStayEvent;
/// Invoked by .
public TriggerEvent2D TriggerStayEvent
{
get
{
if (_TriggerStayEvent == null)
_TriggerStayEvent = new TriggerEvent2D();
return _TriggerStayEvent;
}
set { _TriggerStayEvent = value; }
}
/// Invokes .
public virtual void OnTriggerStay2D(Collider2D collider)
{
if (_TriggerStayEvent != null)
_TriggerStayEvent.Invoke(collider);
}
/************************************************************************************************************************/
[SerializeField]
private TriggerEvent2D _TriggerExitEvent;
/// Invoked by .
public TriggerEvent2D TriggerExitEvent
{
get
{
if (_TriggerExitEvent == null)
_TriggerExitEvent = new TriggerEvent2D();
return _TriggerExitEvent;
}
set { _TriggerExitEvent = value; }
}
/// Invokes .
public virtual void OnTriggerExit2D(Collider2D collider)
{
if (_TriggerExitEvent != null)
_TriggerExitEvent.Invoke(collider);
}
/************************************************************************************************************************/
}
}