本身是带热更新的,当发布新包时,如何清空原有热更资源,从新包的默认资源启动?
我尝试这样做,再发现build编号不一致时,就清空资源,更改资源路径回到包中自带的资源。但发现还是自动更新了资源。这应该如何处理呢?
checkBuild() {
// var hotUpdateSearchPaths = localStorage.getItem('HotUpdateSearchPaths');
// this.log('checkBuild: hotUpdateSearchPaths', hotUpdateSearchPaths);
// var searchPaths = (<any>jsb).fileUtils.getSearchPaths();
// this.log('checkBuild: searchPaths', searchPaths);
let lastBuild = cc.sys.localStorage.getItem('currentBuild');
let currentBuild = globalThis.AppInfoManager.getInstance().getBuild();
cc.sys.localStorage.setItem('currentBuild', currentBuild);
if (Common.MyString.isNullOrEmpty(currentBuild)) {
this.log('没有之前的版本,当前的版本是:', currentBuild, 'storagePath', this._storagePath);
jsb.fileUtils.removeDirectory(this._storagePath);
}
else {
this.log('比较版本:', lastBuild, currentBuild);
if (lastBuild != currentBuild) {
this.log('构建编号更新,删除缓存资源', this._storagePath);
jsb.fileUtils.removeDirectory(this._storagePath);
// jsb.fileUtils.setSearchPaths(["@assets/"]);
jsb.fileUtils.setSearchPaths([]);
cc.sys.localStorage.removeItem('HotUpdateSearchPaths');
// 重启一下
// cc.audioEngine.stopAll();
// cc.game.restart();
// return true;
}
}
return false;
}