unity如何实现延迟回调工具
发表于:2024-10-19 作者:千家信息网编辑
千家信息网最后更新 2024年10月19日,这篇文章主要介绍unity如何实现延迟回调工具,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!一个实用的计时器,可以计时延迟调用和延迟重复次数调用。可以自己封装成单例模式挂在Ga
千家信息网最后更新 2024年10月19日unity如何实现延迟回调工具
这篇文章主要介绍unity如何实现延迟回调工具,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
一个实用的计时器,可以计时延迟调用和延迟重复次数调用。
可以自己封装成单例模式挂在GameObject上使用,或者在另一个behavior的Update里执行这个类的OnUpdate()方法再使用。
为了更加安全的使用,建议在销毁MonoBehaviour时清理一下对应的所有计时器。
或者调用时可选择传入回调所在的MonoBehaviour,这样就可以自动清理了。
using System.Collections;using System;using System.Collections.Generic;using UnityEngine;public static class DelayCall{ private static Listcalltimes = new List (); private static Dictionary callsort = new Dictionary (); private static int countid = 0; /// /// 生成id /// ///The new identifier. /// Call. private static int getNewId(CallObj call) { countid++; if (countid >= int.MaxValue) { countid = 1; } while (callsort.ContainsKey(countid)) countid++; call.callid = countid; callsort.Add(countid, call); return countid; } public static void ClearAll() { calltimes.Clear(); callsort.Clear(); } ////// 删除延迟执行. /// /// /// Call. /// public static void remove(int callid) { if (callid > 0 && callsort.ContainsKey(callid)) { CallObj call = callsort[callid]; callsort.Remove(callid); if (call != null) { calltimes.Remove((CallTimeObj)call); } } } public static int AddTime(float delayTime, object arg, int repeat = 1,Action
以上是"unity如何实现延迟回调工具"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
延迟
方法
工具
内容
时间
次数
篇文章
计时器
实用
安全
价值
兴趣
函数
实例
小伙
小伙伴
建议
所在
更多
模式
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
软件开发工程造价培训
深圳鸿湾软件开发有限公司
易语言数据库建立
搭建服务器机房
数据库如何获取openid
郑州网络安全产业园总经理
深圳软件开发教学
网络安全工程师相关政策
数据库执行超时设置
镇网络安全宣传周实施方案
陕警院网络安全执法专业
ssm框架访问厂家数据库
服务器登录用户名怎么查
嵌入式存储服务器
阿里巴巴平台服务器登录
ios连接服务器失败
execel 连接数据库
qq交换网络技术
关系数据库有
新闻类数据库设计
广州智慧电梯软件开发报价
网络安全技术及应用第三章答案
支吊架数据库下载
关系数据库 主键
生物学数据库的介绍
网页信息采集软件开发
广东省计算机网络技术单招面试
服务器mongodb配置
数据库求成绩总和的sql语句
张家界昱晟网络技术服务有限公司