Esempio n. 1
0
    /// <summary>
    /// 生成AB资源文件列表
    /// </summary>
    public static void CreateAssetBundleFileInfo()
    {
        string abRootPath  = GetExportPath();
        string abFilesPath = abRootPath + "/" + AppSetting.ABFiles;

        if (File.Exists(abFilesPath))
        {
            File.Delete(abFilesPath);
        }

        var abFileList = new List <string>(Directory.GetFiles(abRootPath, "*" + AppSetting.ExtName, SearchOption.AllDirectories));

        abFileList.Add(abRootPath + Utility.GetPlatformName());
        FileStream   fs = new FileStream(abFilesPath, FileMode.CreateNew);
        StreamWriter sw = new StreamWriter(fs);

        DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2018, 1, 1));
        int      ver       = ((int)((DateTime.Now - startTime).TotalMinutes));

        sw.WriteLine(ver + "|" + DateTime.Now.ToString("u"));
        for (int i = 0; i < abFileList.Count; i++)
        {
            string file  = abFileList[i];
            long   size  = 0;
            string md5   = MD5Utils.MD5File(file, out size);
            string value = file.Replace(abRootPath, string.Empty).Replace("\\", "/");
            sw.WriteLine(value + "|" + md5 + "|" + size);
        }
        sw.Close();
        fs.Close();
        Debug.LogError("资源版本Version:" + ver + "  已复制到剪切板");
        Debug.LogError("ABFiles文件生成完成");
        MyEditorTools.CopyString(ver.ToString());
    }