栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 游戏开发 > 其他

cannot open tolua.lua: No such file or directory

其他 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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 directory
no 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_STANDALONE
    public static string osDir = "Win";
#elif UNITY_ANDROID
    public static string osDir = "luaframework";//查看手机 luaframework 文件路径是在 luaframework  不是 Android,
#elif UNITY_IPHONE
    public static string osDir = "iOS";        
#else
    public static string osDir = "";        
#endif

    public 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:
感谢!

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/901472.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号