コード例 #1
0
        public void Dispose(string bundleName)
        {
            if (!mNameBundleDict.ContainsKey(bundleName))
            {
                Debug.LogError("没有加载" + bundleName + "无法加载");
                return;
            }

            AssetBundleRelation assetBundleRelation = mNameBundleDict[bundleName];

            string[] allDependences = assetBundleRelation.GetAllDependence();

            foreach (var dependenceBundleName in allDependences)
            {
                AssetBundleRelation tempAssetBundleRelation = mNameBundleDict[bundleName];
                bool resualt = tempAssetBundleRelation.RemoveReferenceBundle(bundleName);

                if (resualt)
                {
                    //递归
                    Dispose(tempAssetBundleRelation.BundleName);
                }
            }

            //TODO:有错误
            mNameBundleDict[bundleName].Dispose();
            mNameBundleDict[bundleName] = null;
        }
コード例 #2
0
        /// <summary>
        /// 加载资源包
        /// </summary>
        /// <param name="bundleName"></param>
        /// <param name="loadProgress"></param>
        /// <param name="loadAssetBundleCallback"></param>
        public void LoadAssetBundle(string bundleName, LoadProgress loadProgress,
                                    LoadAssetBundleCallback loadAssetBundleCallback)
        {
            if (mNameBundleDict.ContainsKey(bundleName))
            {
                Debug.LogWarning("已经加载了" + bundleName);
                return;
            }

            AssetBundleRelation assetBundleRelation = new AssetBundleRelation(bundleName, loadProgress);

            mNameBundleDict.Add(bundleName, assetBundleRelation);
            loadAssetBundleCallback(mSceneName, bundleName);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bundleName"></param>
        /// <param name="referenceBundleName"></param>
        /// <param name="loadProgress"></param>
        /// <returns></returns>
        private IEnumerator LoadDependence(string bundleName, string referenceBundleName, LoadProgress loadProgress)
        {
            if (mNameBundleDict.ContainsKey(bundleName))
            {
                AssetBundleRelation assetBundleRelation = mNameBundleDict[bundleName];

                assetBundleRelation.AddReferenceBundle(referenceBundleName);
            }
            else
            {
                AssetBundleRelation assetBundleRelation = new AssetBundleRelation(bundleName, loadProgress);
                assetBundleRelation.AddReferenceBundle(referenceBundleName);
                mNameBundleDict.Add(bundleName, assetBundleRelation);
                yield return(Load(bundleName));
            }
        }
コード例 #4
0
        public IEnumerator Load(string bundleName)
        {
            while (!AssetBundleManifestLoader.Instance.Finish)
            {
                yield return(null);
            }

            AssetBundleRelation assetBundleRelation = mNameBundleDict[bundleName];

//        assetBundleRelation.GetAllDependence();

            string[] dependencesBundles = AssetBundleManifestLoader.Instance.GetDependences(bundleName);

            foreach (var item in dependencesBundles)
            {
                assetBundleRelation.AddDependence(item);
                yield return(LoadDependence(item, bundleName, assetBundleRelation.LoadProgress));
            }

            yield return(assetBundleRelation.Load());
        }