Inheritance: UnityEngine.MonoBehaviour
        /// <summary>
        /// Confirms the instance is ready for use
        /// </summary>
        public static void ConfirmInit()
        {
            if (_instance == null)
            {
                var old = FindObjectsOfType<TaskManager>();
                foreach (var manager in old)
                {
                    if (Application.isEditor)
                        DestroyImmediate(manager.gameObject);
                    else
                        Destroy(manager.gameObject);
                }

                var go = new GameObject("_TaskManager");
                DontDestroyOnLoad(go);
                _instance = go.AddComponent<TaskManager>();

                MainThread = CurrentThread;
            }
        }
 protected void Awake()
 {
     if (_instance == null)
         _instance = this;
 }
        /// <summary>
        /// Adds a timeout to the task. Will raise an exception if still running
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <param name="seconds"></param>
        /// <param name="onTimeout"></param>
        /// <returns></returns>
        public static T AddTimeout <T>(this T self, int seconds, Action <UnityTask> onTimeout = null) where T : UnityTask
        {
            TaskManager.StartRoutine(TimeOutAsync(self, seconds, onTimeout));

            return(self);
        }
Exemple #4
0
 static UnityTask()
 {
     TaskManager.ConfirmInit();
 }
Exemple #5
0
 protected void RunOnMainThread()
 {
     Status = TaskStatus.Pending;
     TaskManager.RunOnMainThread(Execute);
 }
Exemple #6
0
        static AsyncTask()
        {
#if UNITY
            TaskManager.ConfirmInit();
#endif
        }