// UltEvents // Copyright 2020 Kybernetik //
using UnityEngine;
namespace UltEvents
{
///
/// An event that takes a single parameter.
///
[System.Serializable]
public sealed class CollisionEvent2D : UltEvent { }
/************************************************************************************************************************/
///
/// Holds s which are called by various 2D collision events:
/// , , and .
///
[AddComponentMenu(UltEventUtils.ComponentMenuPrefix + "Collision Events 2D")]
[HelpURL(UltEventUtils.APIDocumentationURL + "/CollisionEvents2D")]
[DisallowMultipleComponent]
[RequireComponent(typeof(Collider2D))]
public class CollisionEvents2D : MonoBehaviour
{
/************************************************************************************************************************/
[SerializeField]
private CollisionEvent2D _CollisionEnterEvent;
/// Invoked by .
public CollisionEvent2D CollisionEnterEvent
{
get
{
if (_CollisionEnterEvent == null)
_CollisionEnterEvent = new CollisionEvent2D();
return _CollisionEnterEvent;
}
set { _CollisionEnterEvent = value; }
}
/// Invokes .
public virtual void OnCollisionEnter2D(Collision2D collision)
{
if (_CollisionEnterEvent != null)
_CollisionEnterEvent.Invoke(collision);
}
/************************************************************************************************************************/
[SerializeField]
private CollisionEvent2D _CollisionStayEvent;
/// Invoked by .
public CollisionEvent2D CollisionStayEvent
{
get
{
if (_CollisionStayEvent == null)
_CollisionStayEvent = new CollisionEvent2D();
return _CollisionStayEvent;
}
set { _CollisionStayEvent = value; }
}
/// Invokes .
public virtual void OnCollisionStay2D(Collision2D collision)
{
if (_CollisionStayEvent != null)
_CollisionStayEvent.Invoke(collision);
}
/************************************************************************************************************************/
[SerializeField]
private CollisionEvent2D _CollisionExitEvent;
/// Invoked by .
public CollisionEvent2D CollisionExitEvent
{
get
{
if (_CollisionExitEvent == null)
_CollisionExitEvent = new CollisionEvent2D();
return _CollisionExitEvent;
}
set { _CollisionExitEvent = value; }
}
/// Invokes .
public virtual void OnCollisionExit2D(Collision2D collision)
{
if (_CollisionExitEvent != null)
_CollisionExitEvent.Invoke(collision);
}
/************************************************************************************************************************/
}
}