コード例 #1
0
        /// <summary>
        /// 检查本地热更信息与服务器热更信息比较
        /// </summary>
        /// <returns></returns>
        bool CheckLocalAndServerPatch()
        {
            if (!File.Exists(m_LocalXmlPath))
            {
                return(true);
            }

            m_LocalInfo = BinarySerializeOpt.XmlDeserialize(m_LocalXmlPath, typeof(ServerInfo)) as ServerInfo;

            VersionInfo localGameVesion = null;

            if (m_LocalInfo != null)
            {
                foreach (VersionInfo version in m_LocalInfo.GameVersion)
                {
                    if (version.Version == m_CurVersion)
                    {
                        localGameVesion = version;
                        break;
                    }
                }
            }

            if (localGameVesion != null && m_GameVersion.Pathces != null && localGameVesion.Pathces != null && m_GameVersion.Pathces.Length > 0 && m_GameVersion.Pathces[m_GameVersion.Pathces.Length - 1].Version != localGameVesion.Pathces[localGameVesion.Pathces.Length - 1].Version)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        IEnumerator ReadXml(Action callBack)
        {
            string xmlUrl = "http://annuzhiting2.oss-cn-hangzhou.aliyuncs.com/ServerInfo.xml";

            UnityWebRequest webRequest = UnityWebRequest.Get(xmlUrl);

            webRequest.timeout = 30;
            yield return(webRequest.SendWebRequest());

            if (webRequest.isNetworkError)
            {
                Debug.Log("Download Error" + webRequest.error);
            }
            else
            {
                FileTool.CreateFile(m_ServerXmlPath, webRequest.downloadHandler.data);
                if (File.Exists(m_ServerXmlPath))
                {
                    m_ServerInfo = BinarySerializeOpt.XmlDeserialize(m_ServerXmlPath, typeof(ServerInfo)) as ServerInfo;
                }
                else
                {
                    Debug.LogError("热更配置读取错误!");
                }
            }

            if (callBack != null)
            {
                callBack();
            }
        }
コード例 #3
0
        static void CopyAbAndGeneratJson(List <string> changeList, string hotCount)
        {
            if (!Directory.Exists(m_HotPath))
            {
                Directory.CreateDirectory(m_HotPath);
            }
            DeleteAllFile(m_HotPath);
            foreach (string str in changeList)
            {
                if (!str.EndsWith(".manifest"))
                {
                    File.Copy(m_BunleTargetPath + "/" + str, m_HotPath + "/" + str);
                }
            }

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

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

            pathces.Version = 1;
            pathces.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 = "http://annuzhiting2.oss-cn-hangzhou.aliyuncs.com/AssetBundle/" + PlayerSettings.bundleVersion + "/" + hotCount + "/" + files[i].Name;
                pathces.Files.Add(patch);
            }

            BinarySerializeOpt.Xmlserialize(m_HotPath + "/Patch.xml", pathces);
        }