unity 延时调用方法
来源:互联网 发布:淘宝怎么删掉评价 编辑:程序博客网 时间:2024/06/08 21:02
using UnityEngine;using System.Collections;using System.Collections.Generic;/// <summary>/// 使用Time.time控制时间间隔调用方法/// </summary>public class ProcessControl { static System.Action _action; static float currentTime; static float _delayTime; static Queue<System.Action> qAction = new Queue<System.Action>(); public static void InvokeAfterSecond(System.Action action, float delayTime) { _action = action; currentTime = Time.time; _delayTime = delayTime; } public static void InvokeFuncListAfterSecond(Queue<System.Action> action, float delayTime) { qAction = action; currentTime = Time.time; _delayTime = delayTime; } public static void Update() { if (Time.time > currentTime + _delayTime) { foreach (var item in qAction) { item(); } currentTime = 0; _delayTime = int.MaxValue; } } public static Queue<System.Action> AddFun(System.Action action) { qAction.Enqueue(action); return qAction; }}public class TestTimeControl:MonoBehaviour{ void Start() { ProcessControl.InvokeFuncListAfterSecond(ProcessControl.AddFun( () => { Debug.Log("3"); Print1(); Print2(); }), 3); } void Update() { ProcessControl.Update(); } void Print1() { Debug.Log("print1"); } void Print2() { Debug.Log("print2"); } }
0 0
- unity 延时调用方法
- Unity 延时调用(Invoke)
- 延时递归调用方法
- unity中的简单延时方法
- 动态调用方法 延时调用方法
- Unity延时方法Invoke和InvoleRepeating
- unity自带延时执行方法
- Unity调用方法注入
- Unity 调用Android方法
- Unity调用OC方法
- unity 调用android方法
- Unity调用Android方法
- Unity4.6.3之间隔、延时调用方法
- unity延时方法Invoke和InvokeRepeating(方法技术记载)
- unity简单调用Android方法
- 极简Unity调用Android方法
- Unity基础,基本方法调用
- Unity - 延时操作方案
- 如何处理Tableview中cell的单选问题
- Unity学习笔记(2) --- Unity脚本的生命周期
- poj3273
- cocos2d-x v2 和 v3 对照手册
- 设计模式之单例、多例模式
- unity 延时调用方法
- mysql命令
- python2.7.10
- 修改数据库名 -----表名 ------属性名等
- 大话设计模式_桥接模式c++实现
- ShareSDK集成登陆功能
- [BZOJ1231] [Usaco2008 Nov]mixup2 混乱的奶牛
- 115 html IE9的a标签嵌套问题
- 关于协方差