示例#1
0
    public static void BuildFileList(bool show_dialog)
    {
        Clear();

        DateTime dt1 = System.DateTime.UtcNow;
        // 获取AssetBundleManifest;
        string manifestPath          = string.Format("{0}/{1}", PackAssetBundle.bundleBuildFolder, ResourceConst.PkgBundleFolder);
        AssetBundleManifest manifest = PackBundleTools.GetAssetBundleManifest(manifestPath);

        if (manifest == null)
        {
            return;
        }

        // 计算总控文件;
        AddBundleInfo(ResourceConst.PkgBundleFolder, ref s_FileList);

        // 计算Config;
        AddConfInfo(s_FileList);

        // 计算其它文件;
        string[] allBundleKeyList = manifest.GetAllAssetBundles();
        for (int i = 0; i < allBundleKeyList.Length; i++)
        {
            string file = allBundleKeyList[i];
            if (string.IsNullOrEmpty(file))
            {
                continue;
            }
            AddBundleInfo(file, ref s_FileList);

            PackAssetBundleUtlis.ShowProgress(i, allBundleKeyList.Length, "计算MD5:", file);
        }
        EditorUtility.ClearProgressBar();

        string   strFileList = string.Format("{0}.txt", ResourceConst.FileListName);
        DateTime dt2         = System.DateTime.UtcNow;

        BuildCommon.WriteJsonToFile(PackAssetBundle.bundleBuildFolder, strFileList, s_FileList);

        FileDepencies.WriteMd5Info();

        DateTime dt3 = System.DateTime.UtcNow;

        BuildFileListAssetBundle(PackAssetBundle.bundleBuildFolder, strFileList, ResourceConst.FileListName);

        DateTime dt4 = System.DateTime.UtcNow;

        if (show_dialog)
        {
            string info = string.Format("FileList生成完成,总时长{0}秒", (dt4 - dt1).TotalSeconds.ToString("f1"));
            EditorUtility.DisplayDialog("打包完成", info, "好的");
        }
    }
示例#2
0
    private static FileList ReadFileList(string path)
    {
        string fileName = System.IO.Path.GetFileName(path);

        if (string.Equals(fileName, ResourceConst.FileListName))
        {
            return(PackBundleTools.GetAssetBundleFileListFromAbsPath(path));
        }

        if (string.Equals(fileName, ResourceConst.FileListName + ".txt"))
        {
            return(BuildCommon.ReadJsonFromFile <FileList>(path));
        }

        return(null);
    }
    public static string CompareFileList(BundleUpdateMode mode = BundleUpdateMode.Update_CRC)
    {
        string old_FileListPath = string.Format("{0}/{1}", ResourceConst.BundleFolder, ResourceConst.FileListName);
        string new_fileListPath = string.Format("{0}/{1}", PackAssetBundle.bundleBuildFolder, ResourceConst.FileListName);

        if (!File.Exists(new_fileListPath) || !File.Exists(old_FileListPath))
        {
            return("1");
        }

        FileList new_fileList = PackBundleTools.GetAssetBundleFileList(new_fileListPath);
        FileList old_fileList = PackBundleTools.GetAssetBundleFileList(old_FileListPath);

        if (new_fileList == null || old_fileList == null)
        {
            return("2");
        }

        FileListCompareData compareData = FileList.Compare(new_fileList, old_fileList, true, mode);

        if (compareData == null)
        {
            return("3");
        }

        string update_size = Size2String(compareData.add_size + compareData.modifiy_size);
        string add_size    = Size2String(compareData.add_size);
        string mod_size    = Size2String(compareData.modifiy_size);
        string del_size    = Size2String(compareData.delete_size);

        string strInfo = string.Format("本地打包较上次需要更新{0}({1})", update_size, mode);

        strInfo = string.Format("{0}\n其中:\n增加:{1}", strInfo, add_size);
        strInfo = string.Format("{0}\n改变:{1}", strInfo, mod_size);
        strInfo = string.Format("{0}\n删除:{1}", strInfo, del_size);

        return(strInfo);
    }
示例#4
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));
        }
    }
    public static void CopyAssetBundle(string src, string dest, string conf = "")
    {
        if (string.IsNullOrEmpty(src) || string.IsNullOrEmpty(dest))
        {
            return;
        }

        if (!Directory.Exists(src))
        {
            return;
        }

        string folderName = Path.GetFileName(src);

        dest = string.Format("{0}/{1}", dest, folderName);

        // 清除文件夹;
        FileUtils.ClearDirectory(dest);

        // 拷贝获取AssetBundleManifest文件;
        string topManifest = string.Format("{0}/{1}", src, folderName);

        CopyFile(topManifest, dest + "/" + folderName);

        // 拷贝FileList文件;
        string fileList    = string.Format("{0}/{1}", src, ResourceConst.FileListName);
        string newFileList = string.Format("{0}/{1}", dest, ResourceConst.FileListName);

        CopyFile(fileList, newFileList);

        // 拷贝Conf文件夹;
        if (!string.IsNullOrEmpty(conf))
        {
            string confFolder = string.Format("{0}/{1}", src, conf);
            CopyFolder(confFolder, dest);
        }

        // 拷贝gitlog和md5文件;
        CopyFile(string.Format("{0}/gitlog.txt", src), string.Format("{0}/gitlog.txt", dest));
        //CopyFile(string.Format("{0}/md5_info.txt", src), string.Format("{0}/md5_info.txt", dest));

        // 获取AssetBundleManifest;
        AssetBundleManifest manifest = PackBundleTools.GetAssetBundleManifest(topManifest);

        if (manifest == null)
        {
            return;
        }

        string[] allBundleKeyList = manifest.GetAllAssetBundles();
        for (int i = 0; i < allBundleKeyList.Length; i++)
        {
            string file = allBundleKeyList[i];
            if (string.IsNullOrEmpty(file))
            {
                continue;
            }

            string srcFile  = string.Format("{0}/{1}", src, file);
            string destFile = string.Format("{0}/{1}", dest, file);
            ShowProgress(i, allBundleKeyList.Length, "拷贝", file);
            CopyFile(srcFile, destFile);
        }
        EditorUtility.ClearProgressBar();
    }