From cb653cf75b17b9bdca0b5b9e6b88edf1ca72e90c Mon Sep 17 00:00:00 2001
From: hch <305670599@qq.com>
Date: 星期五, 17 十月 2025 09:54:11 +0800
Subject: [PATCH] 0312 删除旧的日常代码3

---
 Main/Utility/UniTaskExtension.cs |   48 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/Main/Utility/UniTaskExtension.cs b/Main/Utility/UniTaskExtension.cs
index ccade90..2ff6255 100644
--- a/Main/Utility/UniTaskExtension.cs
+++ b/Main/Utility/UniTaskExtension.cs
@@ -4,19 +4,55 @@
 
 public static class UniTaskExtension
 {
-	public static void DelayFrame(this GameObject go, Action action)
+    public static void DelayFrame(this GameObject go, Action action)
     {
-        DelayFrameInternal(action);
+        DelayFrameInternal(1, action);
     }
 
-	public static void DelayFrame(this Component cmp, Action action)
+    public static void DelayFrame(this Component cmp, Action action)
     {
-        DelayFrameInternal(action);
+        DelayFrameInternal(1, action);
     }
 
-    private async static UniTask DelayFrameInternal(Action action)
+    private async static UniTask DelayFrameInternal(int frame, Action action)
     {
-        await UniTask.DelayFrame(1);
+        await UniTask.DelayFrame(frame);
+        action?.Invoke();
+    }
+
+    public static void DelayFrames(this Component cmp, int frames, Action action)
+    {
+        DelayFrameInternal(frames, action);
+    }
+
+    public static void DelayFrames(this GameObject go, int frames, Action action)
+    {
+        DelayFrameInternal(frames, action);
+    }
+
+    public static void DelayFrame(Action action)
+    {
+        DelayFrameInternal(1, action);
+    }
+
+    public static void DelayTime(this GameObject go, float time, Action action)
+    {
+        DelayTimeInternal(time, action);
+    }
+
+    public static void DelayTime(this Component cmp, float time, Action action)
+    {
+        DelayTimeInternal(time, action);
+    }
+
+    private async static UniTask DelayTimeInternal(float time, Action action)
+    {
+        if (time <= 0f)
+        {
+            action?.Invoke();
+            return;
+        }
+        await UniTask.Delay(TimeSpan.FromSeconds(time));
         action?.Invoke();
     }
 }
\ No newline at end of file

--
Gitblit v1.8.0