/// <summary> 开始热更新 </summary>
        private void StartUpdate(Action <bool, string> UpdateCallBack)
        {
            LocalPath = PlatformManager.Instance.GetDataPath(PlatformManager.Instance.Name) + "/";
            ServerUrl = NetcomManager.ABUrl + PlatformManager.Instance.Name + "/";

            XmlLocalVersionPath  = LocalPath + "AssetBundleConfig.xml";
            XmlServerVersionPath = ServerUrl + "AssetBundleConfig.xml";

            if (FileManager.FileExist(XmlLocalVersionPath))
            {
                //读取本地热更文件
                DownLoad(XmlLocalVersionPath, (byte[] bytes) =>
                {
                    localABConfig = bytes != null ? XmlSerializeManager.ProtoDeSerialize <AssetBundleConfig>(bytes) : null;
                    //检查版本更新信息
                    CheckUpdate(localABConfig, () =>
                    {
                        UpdateCallBack?.Invoke(downloadScenes.Count > 0, serverABConfig.Des);
                    });
                });
            }
            else
            {
                //检查版本更新信息
                CheckUpdate(localABConfig, () =>
                {
                    UpdateCallBack?.Invoke(downloadScenes.Count > 0, serverABConfig.Des);
                });
            }
        }
    private void OnEnable()
    {
        titleStyle = new GUIStyle("OL Title")
        {
            alignment = TextAnchor.MiddleCenter,
            fontStyle = FontStyle.Bold,
            fontSize  = 12,
        };

        var bytes = Resources.Load <TextAsset>(configPath).bytes;

        config        = XmlSerializeManager.ProtoDeSerialize <AppScriptConfig>(bytes);
        MainSceneName = config.MainSceneName;

        SceneNames.Add("Global");
        for (var i = 0; i < GetBuildScenes().Length; i++)
        {
            var scene = Path.GetFileNameWithoutExtension(GetBuildScenes()[i]);
            SceneNames.Add(scene);
        }

        level = SceneNames.IndexOf(MainSceneName);

        for (int i = 0; i < config.RootScript.Count; i++)
        {
            int index = SceneNames.IndexOf(config.RootScript[i].SceneName);
            levels.Add(index);
        }
    }
Beispiel #3
0
    public void OnEnable()
    {
        titleStyle = new GUIStyle("OL Title")
        {
            alignment = TextAnchor.MiddleCenter,
            fontStyle = FontStyle.Bold,
            fontSize  = 12,
        };

        var bytes = Resources.Load <TextAsset>(configPath).bytes;

        config = XmlSerializeManager.ProtoDeSerialize <AppTableConfig>(bytes);
    }
    private void Awake()
    {
        TextAsset config = AssetsManager.Instance.LoadAsset <TextAsset>(path_AppTableConfig);

        appTableConfig = XmlSerializeManager.ProtoDeSerialize <AppTableConfig>(config.bytes);
        for (int i = 0; i < appTableConfig.AppTable.Count; i++)
        {
            var bytes = AssetsManager.Instance.LoadAsset <TextAsset>(appTableConfig.AppTable[i].TablePath).bytes;
            if (m_TablePairs.ContainsKey(appTableConfig.AppTable[i].TableName))
            {
                m_TablePairs[appTableConfig.AppTable[i].TableName] = bytes;
            }
            else
            {
                m_TablePairs.Add(appTableConfig.AppTable[i].TableName, bytes);
            }
        }
    }
Beispiel #5
0
    private static void InitRootScripts(Action callback = null)
    {
        TextAsset config = AssetsManager.Instance.LoadAsset <TextAsset>(path_AppScriptConfig);

        appScriptConfig = XmlSerializeManager.ProtoDeSerialize <AppScriptConfig>(config.bytes);
        for (int i = 0; i < appScriptConfig.RootScript.Count; i++)
        {
            if (!iRootPairs.ContainsKey(appScriptConfig.RootScript[i].ScriptName))
            {
                IRoot iRoot;
                //判断是否存在XLua脚本,如果存在,执行XLua代码,不存在执行C#代码
                if (AppConfig.RunXLua && XLuaManager.Instance.IsLuaFileExist(appScriptConfig.RootScript[i].LuaScriptPath))
                {
                    XLuaRoot root = new XLuaRoot();
                    root.Init(appScriptConfig.RootScript[i].LuaScriptPath);
                    iRoot = root;
                }
                else
                {
                    iRoot = GetRoot(appScriptConfig.RootScript[i].ScriptName);
                }
                if (iRoot != null)
                {
                    iRootPairs.Add(appScriptConfig.RootScript[i].ScriptName, iRoot);
                }
                else
                {
                    Debug.LogError($"Root脚本为空 脚本名称:{appScriptConfig.RootScript[i].ScriptName}");
                }
            }
            if (!sceneScriptsPairs.ContainsKey(appScriptConfig.RootScript[i].SceneName))
            {
                List <string> scripts = new List <string>();
                scripts.Add(appScriptConfig.RootScript[i].ScriptName);
                sceneScriptsPairs.Add(appScriptConfig.RootScript[i].SceneName, scripts);
            }
            else
            {
                sceneScriptsPairs[appScriptConfig.RootScript[i].SceneName].Add(appScriptConfig.RootScript[i].ScriptName);
            }
        }

        InitRootBegin("Global", callback);
    }
 /// <summary> 检查更新 </summary>
 private void CheckUpdate(AssetBundleConfig localABConfig, Action cb = null)
 {
     if (Application.internetReachability == NetworkReachability.NotReachable)
     {
         //提示网络错误,检测网络链接是否正常
         Debug.Log("网络异常");
     }
     else
     {
         DownLoad(XmlServerVersionPath, (byte[] bytes) =>
         {
             serverABConfig = XmlSerializeManager.ProtoDeSerialize <AssetBundleConfig>(bytes);
             GetABScenePairs(serverABConfig);
             if (Application.version == serverABConfig.GameVersion)
             {
                 //无大版本更新,校验本地ab包
                 downloadScenes = localABConfig != null ? new List <Scene>() : serverABConfig.Scenes;
                 if (localABConfig != null)
                 {
                     for (int i = 0; i < localABConfig.Scenes.Count; i++)
                     {
                         for (int j = 0; j < localABConfig.Scenes[i].Folders.Count; j++)
                         {
                             if (localABConfig.Scenes[i].Folders[j].MD5 != serverABConfig.Scenes[i].Folders[j].MD5)
                             {
                                 downloadScenes.Add(serverABConfig.Scenes[i]);
                             }
                         }
                     }
                 }
                 LoadTotalSize = downloadScenes.Sum(s => s.Folders.Sum(f => f.Size)) / 1024f;
                 cb?.Invoke();
             }
             else
             {
                 //大版本更新,下载新程序覆盖安装
             }
         });
     }
 }
 public T GetTable <T>(string tableName) where T : class
 {
     return(XmlSerializeManager.ProtoDeSerialize <T>(m_TablePairs[tableName]));
 }