yyl
2025-08-11 b2d7bb59dc37c7b350786b076ee2f344b7c8911f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UnityEngine;
using Cysharp.Threading.Tasks;
using System;
 
public static class UniTaskExtension
{
    public static void DelayFrame(this GameObject go, Action action)
    {
        DelayFrameInternal(1, action);
    }
 
    public static void DelayFrame(this Component cmp, Action action)
    {
        DelayFrameInternal(1, action);
    }
 
    private async static UniTask DelayFrameInternal(int frame, Action action)
    {
        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);
    }
}