Ejemplo n.º 1
0
        void CollectAssetBundle()
        {
            List <string> names = new List <string>(LoadedAssetBundles.Keys);

            for (int i = 0; i < names.Count; i++)
            {
                if (LoadedAssetBundles[names[i]].m_ReferencedCount == 0)
                {
                    LoadedAssetBundles[names[i]].m_AssetBundle.Unload(false);
                    LoadedAssetBundles.Remove(names[i]);
                    BundleDependencies.Remove(names[i]);
                }
            }
            Resources.UnloadUnusedAssets();
        }
Ejemplo n.º 2
0
        void DecreaseRefrenceCount(string assetBundlePath)
        {
            if (LoadedAssetBundles.ContainsKey(assetBundlePath))
            {
                LoadedAssetBundles[assetBundlePath].m_ReferencedCount -= 1;
                var dependencies = BundleDependencies[assetBundlePath];
                for (int index = 0; index < dependencies.Length; index++)
                {
                    DecreaseRefrenceCount(dependencies[index]);
                }

                if (LoadedAssetBundles[assetBundlePath].m_ReferencedCount == 0)
                {
                    LoadedAssetBundles[assetBundlePath].m_AssetBundle.Unload(false);
                    LoadedAssetBundles.Remove(assetBundlePath);
                    BundleDependencies.Remove(assetBundlePath);
                }
            }
        }