Пример #1
0
 public static EditorCoroutine StartCoroutineWithUI(IEnumerator coroutine, string title, bool isCancelable = false)
 {
     if (_uiCoroutineState != null)
     {
         Debug.LogError("EditorCoroutineRunner only supports running one coroutine that draws a GUI! [" + title + "]");
         return(null);
     }
     EditorCoroutineRunner._uiCoroutineState = new EditorCoroutineState(coroutine, title, isCancelable);
     return(StoreCoroutine(_uiCoroutineState));
 }
Пример #2
0
        static void TickState(EditorCoroutineState state)
        {
            if (state.IsValid)
            {
                state.Tick();

                if (state.ShowUi && _uiCoroutineState == state)
                {
                    _uiCoroutineState.UpdateUI();
                }
            }
            else
            {
                _finishedThisUpdate.Add(state);
            }
        }
Пример #3
0
        static EditorCoroutine StoreCoroutine(EditorCoroutineState state)
        {
            if (_coroutineStates == null)
            {
                _coroutineStates    = new List <EditorCoroutineState>();
                _finishedThisUpdate = new List <EditorCoroutineState>();
            }

            if (_coroutineStates.Count == 0)
            {
                EditorApplication.update += Runner;
            }

            _coroutineStates.Add(state);

            return(state.EditorCoroutineYieldInstruction);
        }
Пример #4
0
        public static void KillCoroutine(ref EditorCoroutine coroutine)
        {
            if (_uiCoroutineState.EditorCoroutineYieldInstruction == coroutine)
            {
                _uiCoroutineState = null;
                coroutine         = null;
                EditorUtility.ClearProgressBar();
                return;
            }
            if (KillCoroutine(ref coroutine, ref _coroutineStates))
            {
                return;
            }

            if (KillCoroutine(ref coroutine, ref _finishedThisUpdate))
            {
                return;
            }
        }
Пример #5
0
        static void Runner()
        {
            for (int i = 0; i < _coroutineStates.Count; i++)
            {
                TickState(_coroutineStates[i]);
            }

            for (int i = 0; i < _finishedThisUpdate.Count; i++)
            {
                _coroutineStates.Remove(_finishedThisUpdate[i]);

                if (_uiCoroutineState == _finishedThisUpdate[i])
                {
                    _uiCoroutineState = null;
                    EditorUtility.ClearProgressBar();
                }
            }
            _finishedThisUpdate.Clear();

            if (_coroutineStates.Count == 0)
            {
                EditorApplication.update -= Runner;
            }
        }