Ejemplo n.º 1
0
 public void RemoveAssetBundleCat(AssetBundleCat assetBundleCat)
 {
     if (assetBundleCat == null)
     {
         return;
     }
     LogCat.log(assetBundleCat.assetBundleName + " removed");
     assetBundleCat.Get()?.Unload(true);            //最关键的一步
     assetBundleCatDict.RemoveByFunc((key, value) => value == assetBundleCat);
 }
Ejemplo n.º 2
0
 protected override void _Destroy()
 {
     base._Destroy();
     assetBundleCat     = null;
     _needDownloadBytes = null;
     if (www != null)
     {
         www.Dispose();
         www = null;
     }
 }
Ejemplo n.º 3
0
        public void Init(AssetBundleCat assetBundleCat)
        {
            this.assetBundleName = assetBundleName;
            this.assetBundleCat  = assetBundleCat;
            // 只添加没有被加载过的
            if (!assetBundleCat.IsLoadDone())
            {
                waitingAssetBundleCatDict[assetBundleCat.assetBundleName]      = assetBundleCat;
                assetBundleDownloadedBytesDict[assetBundleCat.assetBundleName] = 0;
            }

            for (var i = 0; i < assetBundleCat.dependenceAssetBundleCatList.Count; i++)
            {
                var dependenceAssetBundleCat = assetBundleCat.dependenceAssetBundleCatList[i];
                if (dependenceAssetBundleCat.IsLoadDone())
                {
                    continue;
                }
                waitingAssetBundleCatDict[dependenceAssetBundleCat.assetBundleName]      = dependenceAssetBundleCat;
                assetBundleDownloadedBytesDict[dependenceAssetBundleCat.assetBundleName] = 0;
            }

            totalWaitingAssetBundleCatCount = waitingAssetBundleCatDict.Count;


            needDownloadBytes = 0;
            foreach (var keyValue in assetBundleDownloadedBytesDict)
            {
                var curAssetBundleName = keyValue.Key;
                needDownloadBytes += Client.instance.assetBundleManager.assetBundleMap.dict[curAssetBundleName];
            }

            if (totalWaitingAssetBundleCatCount == 0)
            {
                resultInfo.isSuccess = true;
                return;
            }

            AddListener <ResourceWebRequester>(null, AssetBundleEventNameConst.On_ResourceWebRequester_Fail,
                                               OnResourceWebRequesterFail);
            AddListener <ResourceWebRequester>(null, AssetBundleEventNameConst.On_ResourceWebRequester_Success,
                                               OnResourceWebRequesterSuccess);
        }
Ejemplo n.º 4
0
        private bool CreateAssetBundleAsync(string assetBundleName)
        {
            if (__IsAssetBundleLoadSuccess(assetBundleName) || resourceWebRequesterAllDict.ContainsKey(assetBundleName))
            {
                return(false);
            }


            // webRequester持有的引用,webRequester结束后会删除该次引用(在AssetBunldeMananger中的OnProsessingWebRequester的进行删除本次引用操作)
            var assetBundleCat = new AssetBundleCat(assetBundleName);

            assetBundleCat.AddRefCount();
            AddAssetBundleCat(assetBundleCat);

            var resourceWebRequester = PoolCatManagerUtil.Spawn <ResourceWebRequester>();
            var url = assetBundleName.WithRootPath(FilePathConst.PersistentAssetBundleRoot);

            resourceWebRequester.Init(assetBundleCat, url);
            resourceWebRequesterAllDict[assetBundleName] = resourceWebRequester;
            resourceWebRequesterWaitingQueue.Enqueue(resourceWebRequester);

            return(true);
        }
Ejemplo n.º 5
0
 protected void AddAssetBundleCat(AssetBundleCat assetBundle)
 {
     assetBundleCatDict[assetBundle.assetBundleName] = assetBundle;
 }
Ejemplo n.º 6
0
 public void Init(AssetBundleCat assetBundleCat, string url, bool isNotCache = false)
 {
     Init(url, isNotCache);
     this.assetBundleCat = assetBundleCat;
     this.assetBundleCat.resourceWebRequester = this;
 }
Ejemplo n.º 7
0
 protected override void _Destroy()
 {
     base._Destroy();
     assetBundleName = null;
     assetBundleCat  = null;
 }