Example #1
0
        static void SetActiveWithDelay(bool value, float delay)
        {
            var inst = LoadingIndicator.instance;

            if (!inst)
            {
                return;
            }

            if (value == inst.activate)
            {
                return;
            }

            if (value && 0 < delay)
            {
                if (0 == inst.waitForDelay)
                {
                    inst.waitForDelay = delay;
                    var gen    = inst.generation;
                    var signal = new CancellableSignal(() => !inst || gen != inst.generation || inst.IsDone);
                    CoroutineTaskManager.AddTask(inst.OnActiveWithDelay(signal,
                                                                        delay,
                                                                        Time.realtimeSinceStartup));
                }
                else
                {
                    inst.waitForDelay = Mathf.Min(inst.waitForDelay, delay);
                }
            }
            else
            {
                inst.OnActive(value);
            }
        }
Example #2
0
            internal void Start()
            {
                this.Stop();

                this.stateErrLog = "";
                this.signal      = new CancellableSignal();
                this.coroutine   = CoroutineTaskManager.AddTask(this.OnStart(this.signal));
            }
Example #3
0
        public static ResourceRequest LoadAsync(CancellableSignal signal,
                                                string popName,
                                                bool foremost = false,
                                                Action <Popup> loadDoneCallback = null)
        {
            if (Popup.testMode)
            {
                if (null != loadDoneCallback)
                {
                    loadDoneCallback(null);
                }

                return(null);
            }

#if LOG_DEBUG
            Debug.Log("POPUP_LOAD_ASYNC:" + popName);
#endif// LOG_DEBUG

            if (!PopupRoot.Instance)
            {
#if LOG_DEBUG
                Debug.Log("POPUP_LOAD_ASYNC_FAILED:" + popName + ", ROOT_IS_NULL");
#endif// LOG_DEBUG
                return(null);
            }

            var popRecycle = Popup.CancelDestroyWithRecycle(popName);
            if (popRecycle)
            {
                if (null != loadDoneCallback)
                {
                    loadDoneCallback(popRecycle);
                }

                return(null);
            }

            Popup.sbPath.Length = Popup.basePath.Length;
            Popup.sbPath.Append(popName);
            string path = Popup.sbPath.ToString();

            var req = Resources.LoadAsync <Popup>(path);
            if (null == req)
            {
#if LOG_DEBUG
                Debug.Log("POPUP_LOAD_ASYNC_FAILED:" + popName + ", PATH:" + path + ", RESOURCES_LOAD_FAILED");
#endif// LOG_DEBUG
                return(null);
            }

            CoroutineTaskManager.AddTask(Popup.OnLoadAsync(signal, req, path, popName, foremost, loadDoneCallback));
            return(req);
        }
Example #4
0
            internal void Stop()
            {
                CancellableSignal.Cancel(this.signal);
                this.signal = null;

                if (this.coroutine != null)
                {
                    CoroutineTaskManager.RemoveTask(this.coroutine);
                    this.coroutine = null;
                }
            }