热更新完后 新的资源没有加载 还是旧的资源,只是检测不到更新了
不知那个环节有错误
设置热更新保存路径为搜索路径
在哪儿设置呢?
我是在main.js一启动时就要设置
(function () {
'use strict';
//------------设置热更新搜索路径-----------------------
var updateAssets = jsb.fileUtils.getWritablePath() + 'update-assets';
var paths = jsb.fileUtils.getSearchPaths();
paths.unshift(updateAssets); //放在数组的第一位
jsb.fileUtils.setSearchPaths(paths);
//--------------------------------------
function boot() {
...
}
})();
var hotUpdateSearchPaths = cc.sys.localStorage.getItem(‘HotUpdateSearchPaths’);
if (hotUpdateSearchPaths) {
jsb.fileUtils.setSearchPaths(JSON.parse(hotUpdateSearchPaths));
}
这个不也是设置 搜索路径的么? 有什么区别么?
没什么区别,要看你调用的时机,在引擎一加载main.js的时候就用执行,不然之后就加载到安装包中的资源了。
要看你的搜索路径中,可写路径是否在最前面
在你的c++代码上打点日志,图片路径打印出来,看看是不是加载的可写路径下的资源
var searchPaths = jsb.fileUtils.getSearchPaths();
var newPaths = this._am.getLocalManifest().getSearchPaths();
cc.log(“newPaths:” + JSON.stringify(newPaths));
this.info.string = “newPaths:” + JSON.stringify(newPaths);
Array.prototype.unshift(searchPaths, newPaths);
// This value will be retrieved and appended to the default search path during game startup,
// please refer to samples/js-tests/main.js for detailed usage.
// !!! Re-add the search paths in main.js is very important, otherwise, new scripts won't take effect.
cc.sys.localStorage.setItem('HotUpdateSearchPaths', JSON.stringify(searchPaths));
jsb.fileUtils.setSearchPaths(searchPaths);
打印了seachPaths:[“assets/res/raw-assets”,"/data/user/0/com.cc/files/remote-asset/",“assets/”] 远程的资源路径没在开头, Array.prototype.unshift(searchPaths, newPaths); 这不是已经设置了么?
你的写法太复杂了吧,searchPaths就是数组,直接用unshift方法插入到头部
...
searchPaths.unshift('xxx');
jsb.fileUtils.setSearchPaths(searchPaths);
如果你非要用Array.prototype.unshift(searchPaths, newPaths); 应该是下面的写法:
Array.prototype.unshift.call(searchPaths, newPaths);
如果newPaths也是数组
searchPaths = newPaths.concat(searchPaths);
Array.concat可以把两个数组的元素连接起来,返回一个新的数组
searchPaths 中好多重复的
seachPaths:["/data/user/0/com.cc/files/remote-asset/",“assets/res/raw-assets”,"/data/user/0/com.cc/files/remote-asset/",“assets/”]
啊,还是旧的资源
大佬,有qq 么 或者微信 加一下 ,我的qq :438294680
生成mainfest时使用路径分隔符使用"/",不要使用""

