Ejemplo n.º 1
0
        public void Update()
        {
            if (manifest == null)
            {
                return;
            }

            List <string> loaded = new List <string>();

            foreach (var item in dicAssetBundleCreateRequest)
            {
                AssetBundleCreateRequest request = item.Value;
                if (request.isDone)
                {
                    AssetBundle     bundle            = request.assetBundle;
                    AssetBundleData loadedAssetBundle = null;
                    if (bundle != null && !dicAssetBundle.TryGetValue(item.Key, out loadedAssetBundle))
                    {
                        loadedAssetBundle = new AssetBundleData(bundle, dicAssetBundleCreateRequestCount[item.Key]);
                        dicAssetBundleCreateRequestCount.Remove(item.Key);

                        dicAssetBundle.Add(item.Key, loadedAssetBundle);
                    }
                    loaded.Add(item.Key);
                }
            }

            int len = loaded.Count;

            for (int i = 0; i < len; i++)
            {
                dicAssetBundleCreateRequest.Remove(loaded[i]);
            }

            // 检测加载进度
            for (int i = 0; i < listProgressOperations.Count;)
            {
                if (!listProgressOperations[i].Update() && listProgressOperations[i].IsDone())
                {
                    if (listProgressOperations[i] is AssetBundleLoadAssetOperation)
                    {
                        AssetBundleLoadAssetOperation assetOP = (listProgressOperations[i] as AssetBundleLoadAssetOperation);
                        if (assetOP.LoadComplete != null)
                        {
                            try
                            {
                                assetOP.LoadComplete(assetOP.GetABData());
                                assetOP.LoadComplete = null;
                            }
                            catch (Exception e)
                            {
                                LogUtil.LogError(e.Message);
                            }
                        }
                        assetOP.Dispose();
                        assetOP = null;
                    }
                    listProgressOperations.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }