Skip to content

Commit a1d3f99

Browse files
committed
将lua与lua.txt分开
1 parent 9bea9fe commit a1d3f99

File tree

9 files changed

+1750
-16
lines changed

9 files changed

+1750
-16
lines changed

Assets/Game/HotFix/Test.lua.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M={}
22

33
function M.Start()
4-
print("Test lua start。!! ")
4+
print("Test lua start! 0")
55
end
66

77
function Update()

Assets/Game/Scripts/Editor/HotFixBuildEditor.cs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,42 @@ namespace GameFramework.Taurus
1818
[InitializeOnLoad]
1919
public static class HotFixBuildEditor
2020
{
21+
private static string _luaFilePath = "Game/Scripts/Lua";
2122
private static string _hotFixPath = "Game/HotFix";
2223

2324
static HotFixBuildEditor()
2425
{
2526
//强制设置unity后台运行
2627
PlayerSettings.runInBackground = true;
2728

28-
string folderPath = Path.Combine(Application.dataPath, _hotFixPath);
29-
30-
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folderPath,"*.lua");
31-
fileSystemWatcher.Changed += (sender, e) =>
32-
{
33-
//if (!EditorApplication.isPlayingOrWillChangePlaymode)
34-
{
35-
File.Copy(e.FullPath, e.FullPath + ".txt", true);
36-
//AssetDatabase.Refresh();
37-
Debug.Log(".lua==>.lua.txt 转换完成");
38-
}
39-
};
29+
_luaFilePath = Path.Combine(Application.dataPath, _luaFilePath);
30+
_hotFixPath = Path.Combine(Application.dataPath, _hotFixPath);
4031

32+
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(_luaFilePath, "*.lua");
33+
fileSystemWatcher.Changed += UpdateLuaTxtFile;
34+
fileSystemWatcher.Created += UpdateLuaTxtFile;
35+
fileSystemWatcher.Deleted += DelecteLuaTxtFile;
36+
37+
//启动事件
4138
fileSystemWatcher.EnableRaisingEvents = true;
42-
4339
}
44-
40+
41+
//删除lua文件
42+
private static void DelecteLuaTxtFile(object sender, FileSystemEventArgs e)
43+
{
44+
string path =Path.Combine(_hotFixPath,Path.GetFileName(e.Name) + ".txt");
45+
if (File.Exists(path))
46+
File.Delete(path);
47+
}
48+
49+
//更新lua文件
50+
private static void UpdateLuaTxtFile(object sender, FileSystemEventArgs e)
51+
{
52+
string path = Path.Combine(_hotFixPath, Path.GetFileName(e.Name) + ".txt");
53+
Debug.Log(path);
54+
File.Copy(e.FullPath, path, true);
55+
Debug.Log(".lua==>.lua.txt 转换完成");
56+
}
4557

4658
}
4759
}

Assets/Game/Scripts/Lua.meta

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

Assets/Game/HotFix/Test.lua renamed to Assets/Game/Scripts/Lua/Test.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
local M={}
22

33
function M.Start()
4-
print("Test lua start。!! ")
4+
print("Test lua start! 0")
55
end
66

77
function Update()

0 commit comments

Comments
 (0)