コード例 #1
0
        // remove  single bundle
        public void DisposeBundle(string bundleName)
        {
            if (loadHelper.ContainsKey(bundleName))
            {
                IABRelationManager loader = loadHelper[bundleName];

                List <string> dependences = loader.GetDependences();

                if (dependences != null)
                {
                    //删除该包 所依赖的包的关系
                    for (int i = 0; i < dependences.Count; i++)
                    {
                        if (loadHelper.ContainsKey(dependences[i]))
                        {
                            loader.RemoveDependence(bundleName);

                            IABRelationManager denpence = loadHelper[dependences[i]];

                            if (denpence.RemoveReferrence(bundleName))
                            {
                                //没有依赖关系了 就删除了
                                string tmpName = denpence.GetBundleName();


                                DisposeBundle(tmpName);
                            }
                        }
                    }
                }

                if (loader.GetReferrence() != null)
                {
                    //删除该包
                    if (loader.GetReferrence().Count <= 0)
                    {
                        loader.Dispose();
                        loadHelper.Remove(bundleName);

                        loader = null;



                        //删除包 加载的  assetbundle.load 出来的内存
                        //	DisposeResObj(bundleName);
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        ///   删除 bundle 镜像
        /// </summary>
        public void DisposeAllBundle()
        {
            List <string> keys = new List <string>();

            keys.AddRange(loadHelper.Keys);

            for (int i = 0; i < loadHelper.Count; i++)
            {
                IABRelationManager loader = loadHelper[keys[i]];

                loader.Dispose();

                //删除Object
                //DisposeResObj(keys[i]);
            }

            loadHelper.Clear();
        }