Files
aibis-dream/Assets/Scripts/Framework/ActionKit/ActionKitMonoBehaviourEvents.cs
T
dingyuntian 9f20ef52d8 UI工具翻新
1. 增加UI工具
2. 增加设置页面
3. GameLoop更新
4. 导入ActionKit工具
2025-04-21 18:53:30 +08:00

70 lines
1.9 KiB
C#

using System;
using System.Collections;
using AibisDream.Framework;
using UnityEngine;
namespace AibisDream.Kit
{
internal class ActionKitMonoBehaviourEvents : Singleton<ActionKitMonoBehaviourEvents>
{
private readonly EasyEvent _onUpdate = new();
private readonly EasyEvent _onFixedUpdate = new();
private readonly EasyEvent _onLateUpdate = new();
private readonly EasyEvent _onGUIEvent = new();
private readonly EasyEvent<bool> _onApplicationFocusEvent = new();
private readonly EasyEvent<bool> _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();
}
}
}