示例#1
0
        public void Load()
        {
            if (_items == null || _items.Count == 0)
            {
                if (_completeCallback != null)
                {
                    _completeCallback.Invoke(this);
                }

                return;
            }

            _needLoadItems = _items.GetRange(0, _items.Count);

            // 是否派发事件
            if (_dispatchEvent)
            {
                DispatchEvent(ResourceManagerEventArgs.QUEUE_START, this);
            }

            // 依次加载子项
            foreach (LoadItem item in _items)
            {
                item.completeCallback += OnItemComplete;
                item.progressCallback += OnItemProgress;
                item.errorCallback    += OnItemError;
                App.resourceManager.Load(item);
            }
        }
示例#2
0
        private void OnItemError(LoadItem item)
        {
            _error = item.error;

            if (_errorCallback != null)
            {
                _errorCallback.Invoke(this);
            }

            if (_dispatchEvent)
            {
                DispatchEvent(ResourceManagerEventArgs.QUEUE_ERROR, this);
            }
        }
示例#3
0
        private void OnItemProgress(LoadItem item)
        {
            _currentItem = item;

            SetLoadItemProgress(item);

            float totalProgress = 0f;

            foreach (LoadItem loadItem in _items)
            {
                totalProgress += loadItem.progress;
            }
            _progress = totalProgress / _items.Count;

            if (_progressCallback != null)
            {
                _progressCallback.Invoke(this);
            }

            if (_dispatchEvent)
            {
                DispatchEvent(ResourceManagerEventArgs.QUEUE_PROGRESS, this);
            }
        }