53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Utils
|
|
{
|
|
public class EventManager : MonoBehaviour
|
|
{
|
|
public delegate void UpdateAction();
|
|
|
|
public static event UpdateAction Updated;
|
|
|
|
public delegate void LateUpdateAction();
|
|
|
|
public static event LateUpdateAction LateUpdated;
|
|
|
|
public delegate void EarlyUpdateAction();
|
|
|
|
public static event EarlyUpdateAction EarlyUpdated;
|
|
|
|
public delegate void LastUpdateAction();
|
|
|
|
public static event LastUpdateAction LastUpdated;
|
|
|
|
|
|
private void Update()
|
|
{
|
|
EarlyUpdated?.Invoke();
|
|
Updated?.Invoke();
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
LateUpdated?.Invoke();
|
|
LastUpdated?.Invoke();
|
|
}
|
|
|
|
public static Delegate[] EarlyUpdateDelegates => EarlyUpdated?.GetInvocationList();
|
|
|
|
public static int EarlyUpdateLength => EarlyUpdateDelegates?.Length ?? 0;
|
|
|
|
public static Delegate[] UpdateDelegates => Updated?.GetInvocationList();
|
|
|
|
public static int UpdateLength => UpdateDelegates?.Length ?? 0;
|
|
|
|
public static Delegate[] LateUpdateDelegates => LateUpdated?.GetInvocationList();
|
|
|
|
public static int LateUpdateLength => LateUpdateDelegates?.Length ?? 0;
|
|
|
|
public static Delegate[] LastUpdateDelegates => LastUpdated?.GetInvocationList();
|
|
|
|
public static int LastUpdateLength => LastUpdateDelegates?.Length ?? 0;
|
|
}
|
|
} |