[Unity] 在协程中等待指定的毫秒

先写一个静态类:

    /// <summary>
    /// 公用基础函数库
    /// <remarks>作者: YangYxd</remarks>
    /// </summary>
    public static class Common {
        /// <summary>
        /// 返回一个以毫秒为单位的时间 (0001-01-01 00:00:00.000 算起)
        /// </summary>
        public static long Ticks {
            get { 
                return (long) (System.DateTime.UtcNow.Ticks * 0.0001f)    ;
            }
        }
    
        public delegate bool CondDelegate(); 

        /// <summary>
        /// 等待指定的毫秒
        /// </summary>
        public static IEnumerator WaitForMillis(long millis, CondDelegate cond = null) { 
            
        } 
    }
    
    

调用方法:

yield return Common.WaitForMillis (5000);
原文地址:https://www.cnblogs.com/yangyxd/p/5361057.html