Esempio n. 1
0
        public bool CancelCurrentTask(int originalTaskId)
        {
            if (CurrentTask == null)
            {
                return(false);
            }

            if (originalTaskId != CurrentTask.GetId() || CurrentTask.IsDone())
            {
                return(false);
            }

            CurrentTask?.Cancel();
            CurrentTask = null;
            return(true);
        }
Esempio n. 2
0
        public void Update()
        {
            if (!IsActive)
            {
                var hasStartedTask = false;

                // Always prefer the auth task over any queued tasks.
                if (queuedAuthTask != null)
                {
                    CurrentTask    = queuedAuthTask();
                    queuedAuthTask = null;
                    hasStartedTask = true;
                }
                else if (queuedTasks.Count > 0)
                {
                    var queuedTask = queuedTasks[0];
                    queuedTasks.RemoveAt(0);

                    CurrentTask    = queuedTask();
                    hasStartedTask = true;
                }

                if (hasStartedTask)
                {
                    if (!isLocked)
                    {
                        EditorApplication.LockReloadAssemblies();
                        isLocked = true;
                    }
                }
                else if (isLocked)
                {
                    EditorApplication.UnlockReloadAssemblies();
                    isLocked = false;
                }
            }
            else
            {
                if (CurrentTask.IsDone())
                {
                    CompletedTasks.Add(CurrentTask);
                    CurrentTask = null;
                }
            }
        }