Ejemplo n.º 1
0
        /// <summary>
        /// 清理
        /// </summary>
        /// <param name="uiState">保留的UI状态名</param>
        public void Clear(JWArrayList <string> uiState)
        {
            if (uiState == null)
            {
                JW.Common.Log.LogE("AssetCache.ClearCache : invalid parameter");
                return;
            }

            Dictionary <string, JWArrayList <BaseAsset> > .Enumerator enumerator = _assets.GetEnumerator();
            while (enumerator.MoveNext())
            {
                JWArrayList <BaseAsset> val = enumerator.Current.Value;
                if (val == null)
                {
                    continue;
                }

                for (int i = val.Count - 1; i >= 0; i--)
                {
                    BaseAsset ba = val[i];
                    if (ba == null)
                    {
                        val.RemoveAt(i);
                        continue;
                    }

                    if (!AssetAssistor.IsAssetDead(ref ba.BaseData, uiState))
                    {
                        continue;
                    }

                    if (AssetProcessor.ProcessDestroy(ba))
                    {
                        if (ba.Resource != null)
                        {
                            ResService.UnloadResource(ba.Resource);
                            ba.Resource = null;
                        }

                        ba.BaseData.Factory.DestroyObject(ba);
                    }
                    else
                    {
                        JW.Common.Log.LogE("AssetCache.ClearCache : failed to process Destroy - {0}", ba.BaseData.Name);
                    }

                    val.RemoveAt(i);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 清除UIState 相关的任务
        /// </summary>
        /// <param name="uiState">保留的UI状态</param>
        public void ClearTask(JWArrayList <string> uiState)
        {
            if (uiState == null)
            {
                JW.Common.Log.LogE("Loader.ClearTask : invalid parameter");
                return;
            }

            if (_synLoading)
            {
                JW.Common.Log.LogE("Loader.ClearTask : load is running");
                return;
            }

            for (int i = _resourceRequesting.Count - 1; i >= 0; --i)
            {
                LoadData loadData = _resourceRequesting[i];
                if (!AssetAssistor.IsAssetDead(ref loadData.Data, uiState))
                {
                    continue;
                }

                if (loadData.Request != null)
                {
                    if (_resourceDiscardRequest != null)
                    {
                        JW.Common.Log.LogE("Loader.ClearTask : _resourceDiscardRequest != null");
                    }

                    _resourceDiscardRequest = loadData.Request;
                }

                _resourceRequesting.RemoveAt(i);
            }

            for (int i = _data.Count - 1; i >= 0; --i)
            {
                AssetData data = _data[i];
                if (data.Priority == LoadPriority.Wait)
                {
                    continue;
                }

                if (AssetAssistor.IsAssetDead(ref data, uiState))
                {
                    _data.RemoveAt(i);
                }
            }
        }