(RealStatePtr L)
| 713 | } |
| 714 | |
| 715 | [MonoPInvokeCallback(typeof(LuaCSFunction))] |
| 716 | internal static int LoadFromStreamingAssetsPath(RealStatePtr L) |
| 717 | { |
| 718 | try |
| 719 | { |
| 720 | string filename = LuaAPI.lua_tostring(L, 1).Replace('.', '/') + ".lua"; |
| 721 | var filepath = UnityEngine.Application.streamingAssetsPath + "/" + filename; |
| 722 | #if UNITY_ANDROID && !UNITY_EDITOR |
| 723 | UnityEngine.WWW www = new UnityEngine.WWW(filepath); |
| 724 | while (true) |
| 725 | { |
| 726 | if (www.isDone || !string.IsNullOrEmpty(www.error)) |
| 727 | { |
| 728 | System.Threading.Thread.Sleep(50); //�Ƚ�hacker������ |
| 729 | if (!string.IsNullOrEmpty(www.error)) |
| 730 | { |
| 731 | LuaAPI.lua_pushstring(L, string.Format( |
| 732 | "\n\tno such file '{0}' in streamingAssetsPath!", filename)); |
| 733 | } |
| 734 | else |
| 735 | { |
| 736 | UnityEngine.Debug.LogWarning("load lua file from StreamingAssets is obsolete, filename:" + filename); |
| 737 | if (LuaAPI.xluaL_loadbuffer(L, www.bytes, www.bytes.Length , "@" + filename) != 0) |
| 738 | { |
| 739 | return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}", |
| 740 | LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1))); |
| 741 | } |
| 742 | } |
| 743 | break; |
| 744 | } |
| 745 | } |
| 746 | #else |
| 747 | if (File.Exists(filepath)) |
| 748 | { |
| 749 | // string text = File.ReadAllText(filepath); |
| 750 | var bytes = File.ReadAllBytes(filepath); |
| 751 | |
| 752 | UnityEngine.Debug.LogWarning("load lua file from StreamingAssets is obsolete, filename:" + filename); |
| 753 | if (LuaAPI.xluaL_loadbuffer(L, bytes, bytes.Length, "@" + filename) != 0) |
| 754 | { |
| 755 | return LuaAPI.luaL_error(L, String.Format("error loading module {0} from streamingAssetsPath, {1}", |
| 756 | LuaAPI.lua_tostring(L, 1), LuaAPI.lua_tostring(L, -1))); |
| 757 | } |
| 758 | } |
| 759 | else |
| 760 | { |
| 761 | LuaAPI.lua_pushstring(L, string.Format( |
| 762 | "\n\tno such file '{0}' in streamingAssetsPath!", filename)); |
| 763 | } |
| 764 | #endif |
| 765 | return 1; |
| 766 | } |
| 767 | catch (System.Exception e) |
| 768 | { |
| 769 | return LuaAPI.luaL_error(L, "c# exception in LoadFromStreamingAssetsPath:" + e); |
| 770 | } |
| 771 | } |
| 772 | #endif |
nothing calls this directly
no test coverage detected