Beispiel #1
0
        public static object SetInterval(System.Action cb, int ms)
        {
            IntervalHandle handle = new IntervalHandle();

            Run(_SetInterval(handle, cb, ms));
            return(handle);
        }
Beispiel #2
0
        public static object SetUpdate(System.Action cb)
        {
            IntervalHandle handle = new IntervalHandle();

            Run(_SetUpdate(handle, cb));
            return(handle);
        }
Beispiel #3
0
        public static object SetTimeout(System.Action cb, int ms)
        {
            IntervalHandle handle = new IntervalHandle();

            handle.Couroutine = Run(_SetTimeout(handle, cb, ms));
            return(handle);
        }
Beispiel #4
0
 public static void ClearInterval(object handle)
 {
     if (handle != null && handle is IntervalHandle)
     {
         IntervalHandle intervalHandle = (IntervalHandle)handle;
         intervalHandle.Running = false;
         Stop(intervalHandle.Couroutine);
     }
 }
Beispiel #5
0
        static IEnumerator _SetTimeout(IntervalHandle handle, System.Action cb, int ms)
        {
            var seconds = ms / 1000.0f;

            yield return(new WaitForSeconds(seconds));

            if (handle.Running)
            {
                cb();
            }
        }
Beispiel #6
0
        static IEnumerator _SetUpdate(IntervalHandle handle, System.Action cb)
        {
            while (true)
            {
                if (handle.Running)
                {
                    cb();
                }
                else
                {
                    yield break;
                }

                yield return(null);
            }
        }
Beispiel #7
0
        static IEnumerator _SetInterval(IntervalHandle handle, System.Action cb, int ms)
        {
            var seconds = ms / 1000.0f;

            while (true)
            {
                var end = Time.realtimeSinceStartup + seconds;
                while (Time.realtimeSinceStartup < end)
                {
                    yield return(null);
                }

                if (handle.Running)
                {
                    cb();
                }
                else
                {
                    yield break;
                }
            }
        }
Beispiel #8
0
		public void ClearInterval (IntervalHandle handle)
		{
		}