diff --git a/Assets/ToLua/Core/LuaFileUtils.cs b/Assets/ToLua/Core/LuaFileUtils.cs index 07ff5f15..df47a6b1 100644 --- a/Assets/ToLua/Core/LuaFileUtils.cs +++ b/Assets/ToLua/Core/LuaFileUtils.cs @@ -113,7 +113,7 @@ public bool RemoveSearchPath(string path) public void AddSearchBundle(string name, AssetBundle bundle) { - zipMap[name] = bundle; + zipMap[name] = bundle; } public string FindFile(string fileName) @@ -124,7 +124,7 @@ public string FindFile(string fileName) } if (Path.IsPathRooted(fileName)) - { + { if (!fileName.EndsWith(".lua")) { fileName += ".lua"; @@ -132,7 +132,7 @@ public string FindFile(string fileName) return fileName; } - + if (fileName.EndsWith(".lua")) { fileName = fileName.Substring(0, fileName.Length - 4); @@ -175,14 +175,14 @@ public virtual byte[] ReadFile(string fileName) { return ReadZipFile(fileName); } - } + } public virtual string FindFileError(string fileName) { if (Path.IsPathRooted(fileName)) { return fileName; - } + } if (fileName.EndsWith(".lua")) { @@ -202,7 +202,7 @@ public virtual string FindFileError(string fileName) if (beZip) { - int pos = fileName.LastIndexOf('/'); + int pos = fileName.LastIndexOf('/'); if (pos > 0) { @@ -212,9 +212,9 @@ public virtual string FindFileError(string fileName) sb.Append(fileName, 0, pos).Replace('/', '_', tmp, pos).Append(".unity3d"); } else - { + { sb.Append("\n\tno file '").Append(fileName).Append(".lua' in ").Append("lua.unity3d"); - } + } } return sb.ToString(); @@ -235,8 +235,8 @@ byte[] ReadZipFile(string fileName) if (pos > 0) { - sb.Append("_"); - sb.Append(fileName, 0, pos).ToLower().Replace('/', '_'); + sb.Append("_"); + sb.Append(fileName, 0, pos).ToLower().Replace('/', '_'); fileName = fileName.Substring(pos + 1); } @@ -245,21 +245,20 @@ byte[] ReadZipFile(string fileName) fileName += ".lua"; } -#if UNITY_5 || UNITY_2017_1_OR_NEWER +#if UNITY_5 || UNITY_5_3_OR_NEWER fileName += ".bytes"; #endif zipName = sb.ToString(); zipMap.TryGetValue(zipName, out zipFile); - } + } if (zipFile != null) { -#if UNITY_5 || UNITY_2017_1_OR_NEWER - TextAsset luaCode = zipFile.LoadAsset(fileName); -#else +#if UNITY_4_6 || UNITY_4_7 TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset; +#else + TextAsset luaCode = zipFile.LoadAsset(fileName); #endif - if (luaCode != null) { buffer = luaCode.bytes; diff --git a/Assets/ToLua/Editor/ToLuaExport.cs b/Assets/ToLua/Editor/ToLuaExport.cs index 6e4d1635..a2730e0d 100644 --- a/Assets/ToLua/Editor/ToLuaExport.cs +++ b/Assets/ToLua/Editor/ToLuaExport.cs @@ -133,7 +133,9 @@ public static class ToLuaExport "Light.areaSize", "Light.lightmappingMode", "Light.lightmapBakeType", - "Security.GetChainOfTrustValue", + "Light.shadowAngle", + "Light.shadowRadius", + "Security.GetChainOfTrustValue", "Texture2D.alphaIsTransparency", "WWW.movie", "WWW.GetMovieTexture", diff --git a/Assets/ToLua/Examples/20_utf8/TestUTF8.cs b/Assets/ToLua/Examples/20_utf8/TestUTF8.cs index 4c22a37b..4834446a 100644 --- a/Assets/ToLua/Examples/20_utf8/TestUTF8.cs +++ b/Assets/ToLua/Examples/20_utf8/TestUTF8.cs @@ -43,11 +43,11 @@ protected override LuaFileUtils InitLoader() protected override void OnLoadFinished() { -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived += ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(ShowTips); #else - Application.RegisterLogCallback(ShowTips); -#endif + Application.logMessageReceived += ShowTips; +#endif base.OnLoadFinished(); luaState.DoString(script); LuaFunction func = luaState.GetFunction("Test"); @@ -68,10 +68,10 @@ void ShowTips(string msg, string stackTrace, LogType type) { base.OnApplicationQuit(); -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived -= ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(null); #else - Application.RegisterLogCallback(null); + Application.logMessageReceived -= ShowTips; #endif } diff --git a/Assets/ToLua/Examples/22_Reflection/TestReflection.cs b/Assets/ToLua/Examples/22_Reflection/TestReflection.cs index b7fee319..00b9a4d0 100644 --- a/Assets/ToLua/Examples/22_Reflection/TestReflection.cs +++ b/Assets/ToLua/Examples/22_Reflection/TestReflection.cs @@ -67,11 +67,11 @@ function Test() protected override LuaFileUtils InitLoader() { -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived += ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(ShowTips); #else - Application.RegisterLogCallback(ShowTips); -#endif + Application.logMessageReceived += ShowTips; +#endif return new LuaResLoader(); } @@ -129,11 +129,11 @@ void ShowTips(string msg, string stackTrace, LogType type) new void OnApplicationQuit() { -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived += ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(ShowTips); #else - Application.RegisterLogCallback(ShowTips); -#endif + Application.logMessageReceived += ShowTips; +#endif Destroy(); } diff --git a/Assets/ToLua/Examples/Performance/TestPerformance.cs b/Assets/ToLua/Examples/Performance/TestPerformance.cs index cfabf9b3..a97216b0 100644 --- a/Assets/ToLua/Examples/Performance/TestPerformance.cs +++ b/Assets/ToLua/Examples/Performance/TestPerformance.cs @@ -12,10 +12,10 @@ public class TestPerformance : MonoBehaviour private void Start() { -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived += ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(ShowTips); #else - Application.RegisterLogCallback(ShowTips); + Application.logMessageReceived += ShowTips; #endif new LuaResLoader(); state = new LuaState(); @@ -32,10 +32,10 @@ void ShowTips(string msg, string stackTrace, LogType type) void OnApplicationQuit() { -#if UNITY_5 || UNITY_2017 || UNITY_2018 - Application.logMessageReceived -= ShowTips; +#if UNITY_4_6 || UNITY_4_7 + Application.RegisterLogCallback(null); #else - Application.RegisterLogCallback(null); + Application.logMessageReceived -= ShowTips; #endif state.Dispose(); state = null; diff --git a/README.md b/README.md index 3f4ea930..debff2c5 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ https://github.com/LabOfHoward/unity_tolua-_zerobrane_api
* 当lua出现异常,能够同时捕获c#端和lua端堆栈,便于调试
* print信息,在编辑器点击日志, 能自动打开对应lua文件
* 支持unity所有版本
+* **支持Lua hook C#相代码实现,一定程度上支持利用Lua代码修改C#端代码的bug**([暖更新使用说明](https://zhuanlan.zhihu.com/p/35124260)) 
# 快速入门 在CustomSetting.cs中添加需要导出的类或者委托,类加入到customTypeList列表,委托加入到customDelegateList列表
@@ -199,4 +200,4 @@ iOS(il2cpp): IPhone6 Plus
# About Lua win, android ios using luajit2.1-beta3. macos using luac5.1.5(for u5.x). -注意iOS未编译模拟器库,请用真机测试 \ No newline at end of file +注意iOS未编译模拟器库,请用真机测试