Пример #1
0
    private static void ZipRes()
    {
        if (_verRes <= 1)
        {
            return;
        }

        string pathPlatVerLast = VerPath(_verRes - 1);
        string zipPath         = Config.WwwRootPath + "res/" + _platform + "/";
        string zipFile         = zipPath + _verRes + ".zip";

        List <string> listResInfoDiff = GetFileInfoDiff(_pathPlatVer + "resourcesinfo", pathPlatVerLast + "resourcesinfo");

        Dictionary <string, string> dictZipFile = new Dictionary <string, string>();

        dictZipFile.Add(_pathPlatVer + "v" + _verRes, "AssetBundle");
        foreach (string diffFile in listResInfoDiff)
        {
            string diffFile2 = _pathPlatVer + diffFile;
            dictZipFile.Add(diffFile2, diffFile);
        }

        UtilIO.CreateDir(zipPath);
        UtilZip.Zip(dictZipFile, zipFile);
    }
Пример #2
0
    private static void UpdateAssetBundles()
    {
        _pathPlatVer = VerPath(_verRes);
        UtilIO.CreateDir(Config.WwwRootPath);

        ZipRes();
        WriteVerInfo();
    }
Пример #3
0
    private static void BuildAssetBundles(BuildTarget buildTarget)
    {
        _pathPlatVer = VerPath(_verRes);
        UtilIO.CreateDir(_pathPlatVer);

        CopyLua();
        AssetDatabase.Refresh();
        ClearAssetBundleNames();
        SetAssetBundleName();
        AssetBundleManifest mainfest = BuildPipeline.BuildAssetBundles(_pathPlatVer, BuildAssetBundleOptions.UncompressedAssetBundle, buildTarget);

        BuildAssetBundleAfter(mainfest);
    }
Пример #4
0
    /// <summary>
    /// 解压文件
    /// </summary>
    /// <param name="zipFile">压缩文件</param>
    /// <param name="outPath">解压目录</param>
    public static void UnZip(string sourceFile, string targetPath)
    {
        if (!File.Exists(sourceFile))
        {
            Debug.LogError("sourceFile: " + sourceFile + " not exist");
            return;
        }
        UtilIO.CreateDir(targetPath);

        using (var s = new ZipInputStream(File.OpenRead(sourceFile)))
        {
            ZipEntry theEntry;
            while ((theEntry = s.GetNextEntry()) != null)
            {
                if (theEntry.IsDirectory)
                {
                    continue;
                }

                string directorName = Path.Combine(targetPath, Path.GetDirectoryName(theEntry.Name));
                string fileName     = Path.Combine(directorName, Path.GetFileName(theEntry.Name));

                UtilIO.CreateDir(directorName);

                if (!String.IsNullOrEmpty(fileName))
                {
                    using (FileStream streamWriter = File.Create(fileName))
                    {
                        int    size = 4096;
                        byte[] data = new byte[size];
                        while (true)
                        {
                            size = s.Read(data, 0, data.Length);
                            if (size > 0)
                            {
                                streamWriter.Write(data, 0, size);
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
    }