forked from Tencent/xLua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HotfixTest.cs
37 lines (32 loc) · 983 Bytes
/
HotfixTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UnityEngine;
using System.Collections;
using XLua;
[Hotfix]
public class HotfixTest : MonoBehaviour {
LuaEnv luaenv = new LuaEnv();
public int tick = 0; //如果是private的,在lua设置xlua.private_accessible(CS.HotfixTest)后即可访问
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (++tick % 50 == 0)
{
Debug.Log(">>>>>>>>Update in C#, tick = " + tick);
}
}
void OnGUI()
{
if (GUI.Button(new Rect(10, 100, 300, 150), "Hotfix"))
{
luaenv.DoString(@"
xlua.hotfix(CS.HotfixTest, 'Update', function(self)
self.tick = self.tick + 1
if (self.tick % 50) == 0 then
print('<<<<<<<<Update in lua, tick = ' .. self.tick)
end
end)
");
}
}
}