yyl
2026-05-11 51b0f6ed9f4e1d3bb6f8144470b46908c7699a96
Main/Utility/UniTaskExtension.cs
@@ -4,14 +4,14 @@
public static class UniTaskExtension
{
   public static void DelayFrame(this GameObject go, Action action)
    public static void DelayFrame(this GameObject go, Action action)
    {
        DelayFrameInternal(1, action);
        DelayFrameInternal(1, action).Forget();
    }
   public static void DelayFrame(this Component cmp, Action action)
    public static void DelayFrame(this Component cmp, Action action)
    {
        DelayFrameInternal(1, action);
        DelayFrameInternal(1, action).Forget();
    }
    private async static UniTask DelayFrameInternal(int frame, Action action)
@@ -22,11 +22,37 @@
    public static void DelayFrames(this Component cmp, int frames, Action action)
    {
        DelayFrameInternal(frames, action);
        DelayFrameInternal(frames, action).Forget();
    }
    public static void DelayFrames(this GameObject go, int frames, Action action)
    {
        DelayFrameInternal(frames, action);
        DelayFrameInternal(frames, action).Forget();
    }
    public static void DelayFrame(Action action)
    {
        DelayFrameInternal(1, action).Forget();
    }
    public static void DelayTime(this GameObject go, float time, Action action)
    {
        DelayTimeInternal(time, action).Forget();
    }
    public static void DelayTime(this Component cmp, float time, Action action)
    {
        DelayTimeInternal(time, action).Forget();
    }
    private async static UniTask DelayTimeInternal(float time, Action action)
    {
        if (time <= 0f)
        {
            action?.Invoke();
            return;
        }
        await UniTask.Delay(TimeSpan.FromSeconds(time));
        action?.Invoke();
    }
}