예제 #1
0
    static void WriteABMD5()
    {
        DirectoryInfo directoryInfo = new DirectoryInfo(m_BunleTargetPath);

        FileInfo[] files = directoryInfo.GetFiles("*", SearchOption.AllDirectories);
        ABMD5      abmd5 = new ABMD5();

        abmd5.ABMD5List = new List <ABMD5Base> ();
        for (int i = 0; i < files.Length; i++)
        {
            if (!files[i].Name.EndsWith(".meta") && !files[i].Name.EndsWith(".manifest"))
            {
                ABMD5Base abmd5Base = new ABMD5Base();
                abmd5Base.Name = files[i].Name;
                abmd5Base.MD5  = MD5Manager.Instance.BuildFileMd5(files[i].FullName);
                abmd5Base.Size = files[i].Length / 1024.0f;
                abmd5.ABMD5List.Add(abmd5Base);
            }
        }
        string ABMD5Path = Application.dataPath + "/Resources/ABMD5.bytes";

        BinarySerializeOpt.BinarySerilize(ABMD5Path, abmd5);
        //将打版的版本拷贝到外部进行储存
        if (!Directory.Exists(m_VersionMd5Path))
        {
            Directory.CreateDirectory(m_VersionMd5Path);
        }
        string targetPath = m_VersionMd5Path + "/ABMD5_" + PlayerSettings.bundleVersion + ".bytes";

        if (File.Exists(targetPath))
        {
            File.Delete(targetPath);
        }
        File.Copy(ABMD5Path, targetPath);
    }
예제 #2
0
    /// <summary>
    /// xml转二进制
    /// </summary>
    /// <param name="name"></param>
    private static void XmlToBinary(string name)
    {
        if (string.IsNullOrEmpty(name))
        {
            return;
        }

        try
        {
            Type type = null;
            foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                Type tempType = asm.GetType(name);
                if (tempType != null)
                {
                    type = tempType;
                    break;
                }
            }
            if (type != null)
            {
                string xmlPath    = XmlPath + name + ".xml";
                string binaryPath = BinaryPath + name + ".bytes";
                object obj        = BinarySerializeOpt.XmlDeserialize(xmlPath, type);
                BinarySerializeOpt.BinarySerilize(binaryPath, obj);
                Debug.Log(name + "xml转二进制成功,二进制路径为:" + binaryPath);
            }
        }
        catch
        {
            Debug.LogError(name + "xml转二进制失败!");
        }
    }