hch
2025-11-20 ed98029a88cd89702980ac7c40b711afddc5aeb2
Main/Utility/UniTaskExtension.cs
@@ -4,12 +4,12 @@
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);
    }
   public static void DelayFrame(this Component cmp, Action action)
    public static void DelayFrame(this Component cmp, Action action)
    {
        DelayFrameInternal(1, action);
    }
@@ -29,4 +29,30 @@
    {
        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();
    }
}