Ejemplo n.º 1
0
        /// <summary>
        /// 拷贝AB包,生成XML
        /// </summary>
        /// <param name="changeList"></param>
        /// <param name="hotCount"></param>
        static void CopyABAndGeneratXml(List <string> changeList, string hotCount)
        {
            if (!Directory.Exists(m_HotPath))
            {
                Directory.CreateDirectory(m_HotPath);
            }

            BuildApp.DeleteDir(m_HotPath);

            //从AB包目录中,将变化的AB包拷贝到热更目录
            foreach (string str in changeList)
            {
                if (!str.EndsWith(".manifest"))
                {
                    File.Copy(m_BundleTargetPath + "/" + str, m_HotPath + "/" + str);
                }
            }

            //生成服务器Patch文件
            DirectoryInfo directory = new DirectoryInfo(m_HotPath);

            FileInfo[] files   = directory.GetFiles("*", SearchOption.AllDirectories);
            Pathces    patches = new Pathces();

            patches.Version = 1;
            patches.Des     = "";
            patches.Files   = new List <Patch>();
            for (int i = 0; i < files.Length; ++i)
            {
                Patch patch = new Patch();
                patch.Md5      = MD5Manager.Instance.BuildFileMd5(files[i].FullName);
                patch.Name     = files[i].Name;
                patch.Size     = files[i].Length / 1024.0f;
                patch.Platform = EditorUserBuildSettings.activeBuildTarget.ToString();
                patch.Url      = FrameConstr.m_ResServerIp + "AssetBundle/" + PlayerSettings.bundleVersion + "/" + hotCount + "/" + files[i].Name;
                patches.Files.Add(patch);
            }
            BinarySerializeOpt.Xmlserialize(m_HotPath + "/Patch.xml", patches);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 实际的类转XML
        /// </summary>
        /// <param name="name"></param>
        private static void ClassToXml(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)
                {
                    var temp = Activator.CreateInstance(type);
                    if (temp is ExcelBase)
                    {
                        (temp as ExcelBase).Construction();
                    }
                    string xmlPath = XmlPath + name + ".xml";
                    BinarySerializeOpt.Xmlserialize(xmlPath, temp);
                    Debug.Log(name + "类转xml成功,xml路径为:" + xmlPath);
                }
            }
            catch
            {
                Debug.LogError(name + "类转xml失败!");
            }
        }