(RealStatePtr L)
| 682 | |
| 683 | #if !XLUA_GENERAL |
| 684 | [MonoPInvokeCallback(typeof(LuaCSFunction))] |
| 685 | internal static int LoadFromResource(RealStatePtr L) |
| 686 | { |
| 687 | try |
| 688 | { |
| 689 | string filename = LuaAPI.lua_tostring(L, 1).Replace('.', '/') + ".lua"; |
| 690 | |
| 691 | // Load with Unity3D resources |
| 692 | UnityEngine.TextAsset file = (UnityEngine.TextAsset)UnityEngine.Resources.Load(filename); |
| 693 | if (file == null) |
| 694 | { |
| 695 | LuaAPI.lua_pushstring(L, string.Format( |
| 696 | "\n\tno such resource '{0}'", filename)); |
| 697 | } |
| 698 | else |
| 699 | { |
| 700 | if (LuaAPI.xluaL_loadbuffer(L, file.bytes, file.bytes.Length, "@" + filename) != 0) |
| 701 | { |
| 702 | return LuaAPI.luaL_error(L, String.Format("error loading module {0} from resource, {1}", |
| 703 | LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1))); |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | return 1; |
| 708 | } |
| 709 | catch (System.Exception e) |
| 710 | { |
| 711 | return LuaAPI.luaL_error(L, "c# exception in LoadFromResource:" + e); |
| 712 | } |
| 713 | } |
| 714 | |
| 715 | [MonoPInvokeCallback(typeof(LuaCSFunction))] |
| 716 | internal static int LoadFromStreamingAssetsPath(RealStatePtr L) |
nothing calls this directly
no test coverage detected