Example #1
0
    static bool RemoveUnusedAssetBundles(BundleInfoAsset rsd)
    {
        HashSet <string> unusedbundles = new HashSet <string>();
        var a = BundleInfoManager.GetAsset();

        if (a)
        {
            foreach (var v in a.BundleInfos)
            {
                unusedbundles.Add(v.name);
            }
        }
        foreach (var v in rsd.BundleInfos)
        {
            unusedbundles.Remove(v.name);
        }
        int i = 0;

        foreach (var name in unusedbundles)
        {
            i++;
            if (EditorUtility.DisplayCancelableProgressBar(string.Format("remove unused {0}/{1}", i, unusedbundles.Count), name, (float)i / (float)unusedbundles.Count))
            {
                return(false);
            }
            AssetDatabase.RemoveAssetBundleName(name, true);
        }

        return(true);
    }
Example #2
0
    static void RemoveAssetFromBundle(BundleInfoAsset rsd)
    {
        BundleInfoAsset o = BundleInfoManager.GetAsset();

        if (o == null)
        {
            return;
        }

        HashSet <string> oas = new HashSet <string>();

        foreach (var b in o.BundleInfos)
        {
            foreach (var a in b.files)
            {
                oas.Add(a);
            }
        }

        int c  = 0;
        int cc = oas.Count;

        foreach (var b in rsd.BundleInfos)
        {
            foreach (var a in b.files)
            {
                oas.Remove(a);
                c++;
            }
        }

        Debug.Log("remove asset count : " + oas.Count + ", n count : " + c + ", o count : " + cc);
        int i = 0;

        foreach (var a in oas)
        {
            ++i;
            EditorUtility.DisplayProgressBar(string.Format("remove unused asset {0}/{1}", i, oas.Count), a, (float)i / (float)oas.Count);
            SetAssetBundleName(a, "");
        }
    }