xLua hot update solution summary

Recently, I have learned about one of the commonly used solutions for game hot update, xLua. In my opinion, the purpose of xLua hot update solution is to solve the problem of updating the game code and resources when the game has been released and running. No need to republish and reinstall the entire game.

Call the C# code through xLua and hand over the code logic to the Lua language for execution. There is no need to change the original C# code. And after the Lua script provides an entry through C#, the editor does not need to compile and can be run directly.

The xLua solutions are: C# calls Lua Lua calls C# xLua_Hotfix hot patch three main contents

In the general game development process, Lua calls C# and hot patches may be used more often, so I focused on learning these two parts.

In xLua, Lua calls C#'s various types, variables, and functions in different ways. The main purpose of learning is nothing more than how to use them correctly in Lua, as well as the definition syntax and related precautions in xLua (such as: Delegates require attributes to be called correctly, inconsistent differences between nil and null, etc.)

HotFix hot patch: If the project has been written in C#, if it suddenly switches to Lua, or if a function in the C# script is executed and replaced with Lua function logic, hot patching can effectively solve this problem. question

What the hot patch mainly achieves is to replace part of the logic in the C# code, so that the function logic defined in Lua is executed. The replaced function will only execute the logic in Lua (except for the constructor, which is executed in sequence)

Guess you like

Origin blog.csdn.net/m0_69778537/article/details/132791335