unity工具——延迟回调

一个实用的计时器,可以计时延迟调用和延迟重复次数调用。
可以自己封装成单例模式挂在GameObject上使用,或者在另一个behavior的Update里执行这个类的OnUpdate()方法再使用。
为了更加安全的使用,建议在销毁MonoBehaviour时清理一下对应的所有计时器。
或者调用时可选择传入回调所在的MonoBehaviour,这样就可以自动清理了。

using System.Collections;
using System;
using System.Collections.Generic;
using UnityEngine;

public static class DelayCall
{

    private static List<CallTimeObj> calltimes = new List<CallTimeObj>();
    private static Dictionary<i

猜你喜欢

转载自blog.csdn.net/kill566666/article/details/80775582