准备工作:
(1)将XLua的Tool拖入Asset
(2)配置热修复
(3)运行Genrate Code
(4)运行Hotfix Inject In Editor
- 编写脚本(注意类上带有[Hotfix])
[Hotfix]
public class Person2
{
public void Say()
{
Debug.Log("未被修复");
}
}
LuaEnv luaEnv = new LuaEnv();
LuaEnv.DoString(@"
xlua.hotfix(CS.Person2, 'Say',
function()
print('已被修复')
end)
");
Person2 person2 = new Person2();
person2.Say();//打印“已被修复”