hch
63 分钟以前 5c61793c3404cd912c8357eef5fef70bae5bd3d8
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
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);
    }
}