// UltEvents // Copyright 2020 Kybernetik //
using UnityEngine;
namespace UltEvents
{
///
/// Holds s which are called by various lifecycle events:
/// , , , , and
/// .
///
[AddComponentMenu(UltEventUtils.ComponentMenuPrefix + "Life Cycle Events")]
[HelpURL(UltEventUtils.APIDocumentationURL + "/LifeCycleEvents")]
[DisallowMultipleComponent]
public class LifeCycleEvents : MonoBehaviour
{
/************************************************************************************************************************/
[SerializeField]
private UltEvent _AwakeEvent;
/// Invoked by .
public UltEvent AwakeEvent
{
get
{
if (_AwakeEvent == null)
_AwakeEvent = new UltEvent();
return _AwakeEvent;
}
set { _AwakeEvent = value; }
}
/// Invokes .
public virtual void Awake()
{
if (_AwakeEvent != null)
_AwakeEvent.Invoke();
}
/************************************************************************************************************************/
[SerializeField]
private UltEvent _StartEvent;
/// Invoked by .
public UltEvent StartEvent
{
get
{
if (_StartEvent == null)
_StartEvent = new UltEvent();
return _StartEvent;
}
set { _StartEvent = value; }
}
/// Invokes .
public virtual void Start()
{
if (_StartEvent != null)
_StartEvent.Invoke();
}
/************************************************************************************************************************/
[SerializeField]
private UltEvent _EnableEvent;
/// Invoked by .
public UltEvent EnableEvent
{
get
{
if (_EnableEvent == null)
_EnableEvent = new UltEvent();
return _EnableEvent;
}
set { _EnableEvent = value; }
}
/// Invokes .
public virtual void OnEnable()
{
if (_EnableEvent != null)
_EnableEvent.Invoke();
}
/************************************************************************************************************************/
[SerializeField]
private UltEvent _DisableEvent;
/// Invoked by .
public UltEvent DisableEvent
{
get
{
if (_DisableEvent == null)
_DisableEvent = new UltEvent();
return _DisableEvent;
}
set { _DisableEvent = value; }
}
/// Invokes .
public virtual void OnDisable()
{
if (_DisableEvent != null)
_DisableEvent.Invoke();
}
/************************************************************************************************************************/
[SerializeField]
private UltEvent _DestroyEvent;
/// Invoked by .
public UltEvent DestroyEvent
{
get
{
if (_DestroyEvent == null)
_DestroyEvent = new UltEvent();
return _DestroyEvent;
}
set { _DestroyEvent = value; }
}
/// Invokes .
public virtual void OnDestroy()
{
if (_DestroyEvent != null)
_DestroyEvent.Invoke();
}
/************************************************************************************************************************/
}
}