Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions Assets/XLua/Src/StaticLuaCallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -694,17 +694,16 @@ internal static int LoadFromResource(RealStatePtr L)
{
LuaAPI.lua_pushstring(L, string.Format(
"\n\tno such resource '{0}'", filename));
return 1;
}
else

if (LuaAPI.xluaL_loadbuffer(L, file.bytes, file.bytes.Length, "@" + filename) != 0)
{
if (LuaAPI.xluaL_loadbuffer(L, file.bytes, file.bytes.Length, "@" + filename) != 0)
{
return LuaAPI.luaL_error(L, String.Format("error loading module {0} from resource, {1}",
LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
}
return LuaAPI.luaL_error(L, String.Format("error loading module {0} from resource, {1}",
LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
}

return 1;
LuaAPI.lua_pushstring(L, filename);
return 2;
}
catch (System.Exception e)
{
Expand All @@ -717,6 +716,7 @@ internal static int LoadFromStreamingAssetsPath(RealStatePtr L)
{
try
{
int ret = 1;
string filename = LuaAPI.lua_tostring(L, 1).Replace('.', '/') + ".lua";
var filepath = UnityEngine.Application.streamingAssetsPath + "/" + filename;
#if UNITY_ANDROID && !UNITY_EDITOR
Expand All @@ -739,6 +739,8 @@ internal static int LoadFromStreamingAssetsPath(RealStatePtr L)
return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}",
LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
}
LuaAPI.lua_pushstring(L, filename);
ret++;
}
break;
}
Expand All @@ -755,14 +757,16 @@ internal static int LoadFromStreamingAssetsPath(RealStatePtr L)
return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}",
LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
}
LuaAPI.lua_pushstring(L, filename);
ret++;
}
else
{
LuaAPI.lua_pushstring(L, string.Format(
"\n\tno such file '{0}' in streamingAssetsPath!", filename));
}
#endif
return 1;
return ret;
}
catch (System.Exception e)
{
Expand Down Expand Up @@ -791,7 +795,8 @@ internal static int LoadFromCustomLoaders(RealStatePtr L)
return LuaAPI.luaL_error(L, String.Format("error loading module {0} from CustomLoader, {1}",
LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1)));
}
return 1;
LuaAPI.lua_pushstring(L, real_file_path);
return 2;
}
}
LuaAPI.lua_pushstring(L, string.Format(
Expand Down Expand Up @@ -1237,4 +1242,4 @@ public static int ReleaseCsObject(RealStatePtr L)
}
}
}
}
}