添加查找路径无效bug

--引擎3.3final版本
cc.FileUtils:getInstance():addSearchPath(device.writablePath)

在ios上调用上面代码发现图片资源不会优先查找到该路径。

通过跟进堆栈可以看到    lua调用 addSearchPath方法的时候

lua_cocos2dx_runtime_addSearchPath方法进行了路径处理,以“/”开头的路径都会给过滤掉

因此在方法中添加了else 把绝对路径也添加到能添加到搜索路径中

        if (! FileUtils::getInstance()->isAbsolutePath(arg0))
        {
            // add write path to search path
            if (FileServer::getShareInstance()->getIsUsingWritePath())
            {
                cobj->addSearchPath(FileServer::getShareInstance()->getWritePath() + arg0, arg1);
            } else
            {
                cobj->addSearchPath(arg0, arg1);
            }
            
#if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
            // add project path to search path
            cobj->addSearchPath(g_projectPath + arg0, arg1);
#endif
        }
        else //添加的代码
        {
            cobj->addSearchPath(arg0, arg1);
        }


你可能感兴趣的:(添加查找路径无效bug)