public void Init(RectTransform tUi, int speed, Action <RectTransform> pushTaskAction,
                         YuLegoUnloadTask parentTask)
        {
            taskRect = tUi;
            var uiTypeId = GetUiTypeId();

            taskMeta         = metaHelper.GetMeta(uiTypeId);
            unloadSpeed      = speed;
            m_PushTaskAction = pushTaskAction;
            _parentTask      = parentTask;
            willUnloadCount  = taskMeta.WillUnloadCount;
            sonComponentNum  = taskMeta.ComponentRefs.Count;
            sonContainerNum  = taskMeta.ContainerRefs.Count;
            _executeAble     = true;

            string GetUiTypeId()
            {
                if (!tUi.name.Contains("@"))
                {
                    return(tUi.name);
                }

                var finalId = tUi.name.Split('@').First();

                return(finalId);
            }
        }
        public void Update()
        {
            if (!_unloadAble || _taskStack.Count == 0)
            {
                return;
            }

            _unloadExecuteNum++;

            if (_unloadExecuteNum == _totalUnloadSpeed)
            {
                _unloadExecuteNum = 0;
                return;
            }

            while (true)
            {
                _currentTask = _taskStack.Peek();
                if (_currentTask.IsComplete)
                {
                    _unloadingTask.Remove(_currentTask.TaskId);
                    TaskPool.Restore(_currentTask);
                    _taskStack.Pop();
                    if (_taskStack.Count == 0)
                    {
                        return;
                    }

                    _taskStack.Peek().EnableUpdate();
                    continue;
                }

                _currentTask.UnloadAtUpdate();
            }
        }
Beispiel #3
0
        public YuLegoUnloadTask Take(RectTransform uiRect, int unloadSpped,
                                     Action <RectTransform> pushSonTask, YuLegoUnloadTask parentTask)
        {
            var task = TaskPool.Take();

            task.Init(uiRect, unloadSpped, pushSonTask, parentTask);
            return(task);
        }
Beispiel #4
0
 public void Restore(YuLegoUnloadTask task) => TaskPool.Restore(task);