Skip to content

Commit

Permalink
✨ Runner 支持 Update 等 常驻事件订阅
Browse files Browse the repository at this point in the history
  • Loading branch information
xinansky committed Jun 21, 2024
1 parent 856d3e4 commit 2c42d79
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Runtime/Container/Runner.Update.Fix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ partial class Runner
{
#region Nested type: ThreadMono

public static event Action OnFixedUpdate;

partial class ThreadMono
{
private bool mIsUpdateFixedExe;
Expand All @@ -33,6 +35,7 @@ private IEnumerator UpdateFixAction()

public void FixedUpdate()
{
OnFixedUpdate?.Invoke();
if (QueuesDelegateUpdateLateState) return; //判断当前是否有操作正在执行
if (QueuesDelegateUpdateFixed.Count == 0) return; //清空队列中 残留的操作函数
QueuesDelegateUpdateLateState = true; //并开启执行状态
Expand All @@ -56,4 +59,4 @@ public void FixedUpdate()

#endregion
}
}
}
6 changes: 5 additions & 1 deletion Runtime/Container/Runner.Update.Late.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region namespace

using System;
using System.Collections;
#if SUPPORT_UNITASK
using Cysharp.Threading.Tasks;
Expand All @@ -13,6 +14,8 @@ partial class Runner
{
#region Nested type: ThreadMono

public static event Action OnLateUpdate;

private partial class ThreadMono
{
private bool mIsUpdateLateExe;
Expand All @@ -32,6 +35,7 @@ private IEnumerator UpdateLateAction()

public void LateUpdate()
{
OnLateUpdate?.Invoke();
if (QueuesDelegateUpdateFixedState) return; //判断当前是否有操作正在执行
if (QueuesDelegateUpdateLate.Count == 0) return; //清空队列中 残留的操作函数
QueuesDelegateUpdateFixedState = true; //并开启执行状态
Expand All @@ -55,4 +59,4 @@ public void LateUpdate()

#endregion
}
}
}
6 changes: 5 additions & 1 deletion Runtime/Container/Runner.Update.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#region namespace

using System;
using System.Collections;
#if SUPPORT_UNITASK
using Cysharp.Threading.Tasks;
Expand All @@ -13,6 +14,8 @@ partial class Runner
{
#region Nested type: ThreadMono

public static event Action OnUpdate;

partial class ThreadMono
{
private bool mIsUpdateExe;
Expand Down Expand Up @@ -44,6 +47,7 @@ private void UpdateQueue()

public void Update()
{
OnUpdate?.Invoke();
if (!QueuesCoroutineState && !QueuesCoroutine.IsEmpty) UpdateCoroutine();
if (!QueuesDelegateUpdateState && !QueuesDelegateUpdate.IsEmpty) UpdateQueue();
if (!mIsUpdateExe && !QueueCopiedUpdate.IsEmpty)
Expand All @@ -59,4 +63,4 @@ public void Update()

#endregion
}
}
}

0 comments on commit 2c42d79

Please sign in to comment.