using System; using System.Collections; using AibisDream.Framework; using UnityEngine; namespace AibisDream.Kit { internal class ActionKitMonoBehaviourEvents : Singleton { private readonly EasyEvent _onUpdate = new(); private readonly EasyEvent _onFixedUpdate = new(); private readonly EasyEvent _onLateUpdate = new(); private readonly EasyEvent _onGUIEvent = new(); private readonly EasyEvent _onApplicationFocusEvent = new(); private readonly EasyEvent _onApplicationPauseEvent = new(); private readonly EasyEvent _onApplicationQuitEvent = new(); public override void OnSingletonInit() { hideFlags = HideFlags.HideInHierarchy; } private void Update() { _onUpdate?.Trigger(); } private void OnGUI() { _onGUIEvent?.Trigger(); } private void FixedUpdate() { _onFixedUpdate?.Trigger(); } private void LateUpdate() { _onLateUpdate?.Trigger(); } private void OnApplicationFocus(bool hasFocus) { _onApplicationFocusEvent?.Trigger(hasFocus); } private void OnApplicationPause(bool pauseStatus) { _onApplicationPauseEvent?.Trigger(pauseStatus); } // protected override void OnApplicationQuit() // { // OnApplicationQuitEvent?.Trigger(); // base.OnApplicationQuit(); // } public void ExecuteCoroutine(IEnumerator coroutine, Action onFinish) { StartCoroutine(DoExecuteCoroutine(coroutine, onFinish)); } IEnumerator DoExecuteCoroutine(IEnumerator coroutine, Action onFinish) { yield return coroutine; onFinish?.Invoke(); } } }