700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > cannot open tolua.lua: No such file or directory

cannot open tolua.lua: No such file or directory

时间:2020-03-30 14:06:55

相关推荐

cannot open tolua.lua: No such file or directory

项目场景:

`提示:cannot open tolua.lua: No such file or directorytolua

确定有相关文件,但是在安卓手机报错没找到相关文件

问题描述

报错:cannot open tolua.lua: No such file or directorytolua

LuaException: cannot open tolua.lua: No such file or directoryno file './tolua.lua'no file '/usr/local/share/luajit-2.1.0-beta3/tolua.lua'no file '/usr/local/share/lua/5.1/tolua.lua'no file '/usr/local/share/lua/5.1/tolua/init.lua'

原因分析:

提示:路径不对,查找不到:

LuaFileUtils.cs 函数FindFile无法查找到数据,LuaConst.cs 是系统路基脚本

public static class LuaConst{public static string luaDir = Application.dataPath + "/LuaFramework/Lua";//lua逻辑代码目录public static string toluaDir = Application.dataPath + "/LuaFramework/ToLua/Lua"; //tolua lua文件目录#if UNITY_STANDALONEpublic static string osDir = "Win";#elif UNITY_ANDROIDpublic static string osDir = "luaframework";//查看手机 luaframework 文件路径是在 luaframework 不是 Android,#elif UNITY_IPHONEpublic static string osDir = "iOS"; #elsepublic static string osDir = ""; #endifpublic static string luaResDir = string.Format("{0}/{1}/Lua", Application.persistentDataPath, osDir);//手机运行时lua文件下载目录 ...}

解决方案:

修改正确路径LuaConst.cs 修改如上LuaFileUtils.cs。里面有个函数AddSearchPath在LuaState.cs 中有个函数(AddSearchPath)调用,这里也要修改正正确的路径

public void AddSearchPath(string fullPath){if (!Path.IsPathRooted(fullPath)){throw new LuaException(fullPath + " is not a full path");}RuntimePlatform plat= Application.platform;switch (plat){case RuntimePlatform.Android:fullPath = Application.persistentDataPath+ "/luaframework/lua/?.lua";break;default:fullPath = ToPackagePath(fullPath);break;}LuaFileUtils.Instance.AddSearchPath(fullPath); }

搜寻到的解决方案:

安卓上面报错LuaException: cannot open tolua.lua:

感谢!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。