Xlua hot update usage method (2)


Continuing from the previous article, I will study the Hotfix hot update. The
first article is mainly if you use lua and C# mixed development in the development, here is the use of C# development in the project, and use the hot update to fix (patch) when you encounter a bug.
Note: Hot update and Incremental updates are not the same thing. Hot updates can only solve temporary problems. When the version is updated, C# bug fixes are required. At this time, the player updates the new version. When the new version is updated, if the player does not need to download the APP again , Is the incremental update method, the non-incremental update is required to download and install again.

In the era of 5, 6G mobile games, incremental updates are necessary. If it is a terminal game, it is necessary (every tens of G, non-incremental update, it is simply a player's nightmare), incremental update mainly uses the bsdiff tool.

1. Add macro

Insert picture description here

2. Add [HotFix tag] to the already developed C# project

Suppose we have a MyHotFix script that may have bugs or need to modify the logic (to do activities) in the future, we will tag Hotfix
Insert picture description here

3. Execute main at the beginning of the program (all hot update lua are managed through main.lua.txt)

Insert picture description here
Insert picture description here
Insert picture description here

Which script needs to be patched, add require in main and create the corresponding lua file

Insert picture description here

Call hotfix to modify the corresponding script (write new logic in the script, refer to the official writing for details)

4. Test hot update

Insert picture description here

Refer to steps 2, 3

run

Insert picture description here
You can see that I executed a bug once, let's put the execution of main to awak to try
Insert picture description here

Now the logic of the bug is replaced. Update executes the update in lua.
We delete the logic to fix the bug in mian.lua.txt
Insert picture description here

Then execute the script (note that there is no need to recompile here, no need to regenerate Code)
Insert picture description here

You can see that the script executes the previous logic. We can determine whether to modify the logic of a script and how to modify the logic of the script by loading main.

Combine assetbundle and custom loader to achieve hot update

5. Xlua replaces [HotFix tag] with static list

Question: In this case, can all scripts of the project be marked as hot update, and which
ones I want to change will cause problems? What will go wrong?

Refer to the answer given by the author of Xlua: Tagging is not recommended, but lists are recommended (If there are more than one hundred scripts, tagging one by one is still very troublesome. In case some are used and some are not used, it is not easy to manage, use the list to do More convenient configuration)

Insert picture description here
Delete the hotfix tag
Insert picture description here
on MyHotFix Add a script HotfixCfg under the Editor, then add a static list in it, add the MyHotFix class
Insert picture description here
to the list Generate code, inject, and run

Insert picture description here
You can see that it has the same effect as tag MyHotFix with the [Hotfix] tag, and it is easier to manage.
Next article combines AssetBundle to make a complete hot update demo (version check+assetbundle resource download+lua code logic modification)

Guess you like

Origin blog.csdn.net/euphorias/article/details/112848909
Recommended