Exemplo n.º 1
0
        /// <summary>
        /// Run any action after 1 frame
        /// </summary>
        /// <param name="task">the task you want to run after 1 frame</param>
        private IEnumerator DelayActionFrameCoroutine(int frames, IThreadTask task)
        {
            for (int i = 0; i < frames; i++)
            {
                yield return(new WaitForEndOfFrame());
            }

            task.Invoke();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add an action to the unity thread
        /// </summary>
        /// <param name="action">the action</param>
        public void RunOnUnityThread(IThreadTask action)
        {
            if (action == null)
            {
                return;
            }

            if (inUnityThread)
            {
                action.Invoke();
            }
            else
            {
                UnityThreadQueuedActions.Add(action);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when the thread needs to process the task.
        /// </summary>
        /// <param name="processObject"></param>
        protected void OnThreadProcess(System.Object processObject)
        {
            IThreadTask task = processObject as IThreadTask;

            if (task != null)
            {
                try
                {
                    task.Invoke();
                }
                catch (UnityException ex)
                {
                    Debug.LogError("uNature Thread Manager : Error caught while running thread action : \n" + ex);
                }
            }
            else
            {
                Debug.LogError("uNature Thread Manager : Unrecognized thread process : " + processObject.ToString());
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Run any action with a specific delay of seconds.
        /// </summary>
        /// <param name="task">the task you want to run after the specific amount of seconds</param>
        /// <param name="time">the specific amount of seconds to wait</param>
        private IEnumerator DelayActionSecondsCoroutine(IThreadTask task, float time)
        {
            yield return(new WaitForSeconds(time));

            task.Invoke();
        }