Skip to content

Commit

Permalink
还原失误上传的代码
Browse files Browse the repository at this point in the history
  • Loading branch information
NewbieGameCoder committed May 21, 2018
1 parent 2a8eb87 commit c900351
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 39 deletions.
31 changes: 15 additions & 16 deletions Assets/ToLua/Core/LuaFileUtils.cs
Expand Up @@ -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)
Expand All @@ -124,15 +124,15 @@ public string FindFile(string fileName)
}

if (Path.IsPathRooted(fileName))
{
{
if (!fileName.EndsWith(".lua"))
{
fileName += ".lua";
}

return fileName;
}

if (fileName.EndsWith(".lua"))
{
fileName = fileName.Substring(0, fileName.Length - 4);
Expand Down Expand Up @@ -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"))
{
Expand All @@ -202,7 +202,7 @@ public virtual string FindFileError(string fileName)

if (beZip)
{
int pos = fileName.LastIndexOf('/');
int pos = fileName.LastIndexOf('/');

if (pos > 0)
{
Expand All @@ -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();
Expand All @@ -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);
}

Expand All @@ -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<TextAsset>(fileName);
#else
#if UNITY_4_6 || UNITY_4_7
TextAsset luaCode = zipFile.Load(fileName, typeof(TextAsset)) as TextAsset;
#else
TextAsset luaCode = zipFile.LoadAsset<TextAsset>(fileName);
#endif

if (luaCode != null)
{
buffer = luaCode.bytes;
Expand Down
4 changes: 3 additions & 1 deletion Assets/ToLua/Editor/ToLuaExport.cs
Expand Up @@ -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",
Expand Down
14 changes: 7 additions & 7 deletions Assets/ToLua/Examples/20_utf8/TestUTF8.cs
Expand Up @@ -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");
Expand All @@ -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
}

Expand Down
16 changes: 8 additions & 8 deletions Assets/ToLua/Examples/22_Reflection/TestReflection.cs
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down
12 changes: 6 additions & 6 deletions Assets/ToLua/Examples/Performance/TestPerformance.cs
Expand Up @@ -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();
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -79,6 +79,7 @@ https://github.com/LabOfHoward/unity_tolua-_zerobrane_api<br>
* 当lua出现异常,能够同时捕获c#端和lua端堆栈,便于调试 <br>
* print信息,在编辑器点击日志, 能自动打开对应lua文件 <br>
* 支持unity所有版本 <br>
* **支持Lua hook C#相代码实现,一定程度上支持利用Lua代码修改C#端代码的bug**[暖更新使用说明](https://zhuanlan.zhihu.com/p/35124260)) <br>

# 快速入门
在CustomSetting.cs中添加需要导出的类或者委托,类加入到customTypeList列表,委托加入到customDelegateList列表 <br>
Expand Down Expand Up @@ -199,4 +200,4 @@ iOS(il2cpp): IPhone6 Plus<br>

# About Lua
win, android ios using luajit2.1-beta3. macos using luac5.1.5(for u5.x).
注意iOS未编译模拟器库,请用真机测试
注意iOS未编译模拟器库,请用真机测试

0 comments on commit c900351

Please sign in to comment.