準備工作:
(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();//打印“已被修復”