Move events to App class.
This commit is contained in:
@@ -1,61 +1,27 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
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();
|
||||
App.InvokeEarlyUpdate();
|
||||
App.InvokeUpdate();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
LateUpdated?.Invoke();
|
||||
LastUpdated?.Invoke();
|
||||
App.InvokeLateUpdate();
|
||||
App.InvokeLastUpdate();
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
Updated = null;
|
||||
LateUpdated = null;
|
||||
EarlyUpdated = null;
|
||||
LastUpdated = null;
|
||||
App.ClearUpdate();
|
||||
App.ClearLateUpdate();
|
||||
App.ClearEarlyUpdate();
|
||||
App.ClearLastUpdate();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user