Ejemplo n.º 1
0
    public static void DisposeFiles(string folder)
    {
        List <string> old_abs = EditorCommon.GetAllFiles(folder, "*.ab");

        List <string> abs = EditorCommon.GetAllFiles(folder, "*" + ResourceConst.BundleExtensions);

        if (abs == null || abs.Count < 1)
        {
            return;
        }

        foreach (string old_ab in old_abs)
        {
            if (!abs.Contains(old_ab))
            {
                abs.Add(old_ab);
            }
        }

        string fielName = Path.GetFileNameWithoutExtension(folder);

        string path             = string.Format("{0}/{1}", folder, fielName);
        AssetBundleManifest abm = GetAssetBundleManifest(path);

        if (abm == null)
        {
            return;
        }
        string[] files = abm.GetAllAssetBundles();

        foreach (string file in files)
        {
            string bundlePath = string.Format("{0}/{1}", folder, file);
            if (abs.Contains(bundlePath))
            {
                abs.Remove(bundlePath);
            }
        }

        for (int i = 0; i < abs.Count; i++)
        {
            string ab = abs[i];
            System.IO.File.Delete(ab);
            System.IO.File.Delete(string.Format("{0}.manifest", ab));
            ShowProgress(i, abs.Count, "删除无用文件:", ab);
        }
        EditorUtility.ClearProgressBar();
    }
Ejemplo n.º 2
0
    public static void CheckAllBundles(bool tip_dialog = true)
    {
        DateTime dt1 = System.DateTime.UtcNow;
        // 获取所有的Bundle包;
        List <string> bundles = EditorCommon.GetAllFiles(ResourceConst.BundleFolder, "*.*");
        string        folder  = string.Format("{0}/../", Application.dataPath);

        folder = Path.GetFullPath(folder);
        folder = folder.Replace("\\", "/");

        List <string> failed = new List <string>();

        for (int i = 0; i < bundles.Count; i++)
        {
            string filePath = bundles[i];
            if (filePath.EndsWith(".dat") || filePath.EndsWith(".txt"))
            {
                continue;
            }
            bool result = CheckBundle(folder, filePath);
            if (!result)
            {
                failed.Add(filePath);
            }

            ShowProgress(i, bundles.Count, "检测Bundle", "检测Bundle");
        }

        EditorUtility.ClearProgressBar();

        DateTime dt2     = System.DateTime.UtcNow;
        string   strInfo = failed.Count < 1 ? "检测成功,没有错误的Bundle包" : string.Format("检测失败,{0}个Bundle包错误,详情请看Log", failed.Count);

        strInfo = string.Format("检测耗时:{0}秒\n{1}", (dt2 - dt1).TotalSeconds.ToString("f1"), strInfo);

        // 为了使打资源包过程中不停顿,在资源检查错误或者要求有提示信息的时候,才弹出提示框
        if (failed.Count >= 1 || tip_dialog)
        {
            EditorUtility.DisplayDialog("检测完成", strInfo, "好的");
        }
    }
Ejemplo n.º 3
0
    public static void DisposeFiles(string folder, string bundle)
    {
        List <string> abs = EditorCommon.GetAllFiles(folder, "*.ab");

        if (abs == null || abs.Count < 1)
        {
            return;
        }

        string path             = string.Format("{0}/{1}", folder, bundle);
        AssetBundleManifest abm = PackBundleTools.GetAssetBundleManifest(path);

        if (abm == null)
        {
            return;
        }

        string[] files = abm.GetAllAssetBundles();

        foreach (string file in files)
        {
            string bundlePath = string.Format("{0}/{1}", folder, file);
            if (abs.Contains(bundlePath))
            {
                abs.Remove(bundlePath);
            }
            //Debug.Log(file);
        }

        foreach (string ab in abs)
        {
            Debug.Log(ab);
            System.IO.File.Delete(ab);
            System.IO.File.Delete(string.Format("{0}.manifest", ab));
        }
    }