Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 9bea9fe

Browse files
committed
测试zerobrane对lua的调试
1 parent c4c3f1e commit 9bea9fe

File tree

9 files changed

+1768
-4
lines changed

9 files changed

+1768
-4
lines changed

Assets/Game/HotFix/Main.lua

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require('mobdebug').start()
2+
3+
local Test=require("Test")
4+
local q=10
5+
6+
function Start()
7+
q=1000
8+
print("lua start")
9+
print(q)
10+
--CS.GameMode.Resource.Load("hotfix",)
11+
end
12+
13+
function Update()
14+
print("lua update...")
15+
end
16+
17+
function Close()
18+
print("lua close")
19+
end

Assets/Game/HotFix/Main.lua.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Game/HotFix/Main.lua.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
require('mobdebug').start()
2+
13
local Test=require("Test")
4+
local q=10
25

36
function Start()
7+
q=1000
48
print("lua start")
5-
CS.GameMode.Resource.Load("hotfix",)
9+
print(q)
10+
--CS.GameMode.Resource.Load("hotfix",)
611
end
712

813
function Update()

Assets/Game/HotFix/mobdebug.lua.txt

Lines changed: 1707 additions & 0 deletions
Large diffs are not rendered by default.

Assets/Game/HotFix/mobdebug.lua.txt.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Game/Scripts/Editor/HotFixBuildEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static HotFixBuildEditor()
3333
//if (!EditorApplication.isPlayingOrWillChangePlaymode)
3434
{
3535
File.Copy(e.FullPath, e.FullPath + ".txt", true);
36-
AssetDatabase.Refresh();
36+
//AssetDatabase.Refresh();
3737
Debug.Log(".lua==>.lua.txt 转换完成");
3838
}
3939
};

Assets/GameFramework/HotFix/HotFixManager.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ public void LoadHotFix(string assetBundle="hotfix",string luaScript="main",
7676
//自定义加载
7777
private byte[] CustomLoader(ref string filePath)
7878
{
79-
string path = System.IO.Path.Combine(_luaPathPrefix, $"{filePath}.lua.txt");
79+
filePath= System.IO.Path.Combine(_luaPathPrefix, $"{filePath}.lua");
80+
string path = $"{filePath}.txt";// System.IO.Path.Combine(_luaPathPrefix, $"{filePath}.lua.txt");
8081
return _resource.LoadAsset<TextAsset>(_luaAssetBundle,path).bytes;
8182
}
8283

ProjectSettings/ProjectSettings.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ PlayerSettings:
6666
androidBlitType: 0
6767
defaultIsNativeResolution: 1
6868
macRetinaSupport: 1
69-
runInBackground: 0
69+
runInBackground: 1
7070
captureSingleScreen: 0
7171
muteOtherAudioSources: 0
7272
Prepare IOS For Recording: 0

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,28 @@
66

77
`xLua`[https://github.com/Tencent/xLua](https://github.com/Tencent/xLua)
88

9+
`lua ide`[https://studio.zerobrane.com/](https://studio.zerobrane.com/)
10+
11+
`lua MobDebug`[https://github.com/pkulchenko/MobDebug](https://github.com/pkulchenko/MobDebug)
12+
913
目前xLua版本分支,仅为测试版
1014

1115
---
1216

17+
### lua调试
18+
19+
1. 使用[zerobrane](https://studio.zerobrane.com/)进行lua的开发调试
20+
21+
2. 下载[MobDebug](https://github.com/pkulchenko/MobDebug)`mobdebug.lua`在unity里面,在`main.lua`中调用`require('mobdebug').start('127.0.0.1')`进行调试
22+
23+
3.`main.lua`文件拖在`zerobrane`中,选择`Project/Project Directory/Set From Current File`,打开lua的文件夹
24+
25+
4.`zerobrane`中选择`Project/Start Debugger Server`,开启服务调试
26+
27+
5. 然后运行`unity`就可以在`zerobrane`进行断点调试
28+
29+
6. 停止调试的时候,要先停止`unity`,再停止`zerobrane`,不然`unity`也会被`zerobrane`一起关掉
30+
1331
### 内置模块介绍
1432

1533
---

0 commit comments

Comments
 (0)