- 
                Notifications
    You must be signed in to change notification settings 
- Fork 514
Open
Description
Loader.ts 版本:3.2.4
_load2方法中存在以下代码,当content==null一样会缓存起来。实际游戏运行中当网络偶尔出现问题时,会出现content为空的情况,但我们期望网络恢复时能正常加载到该资源,但此时缓存已被null的资源占据导致无法加载到有内容的资源,只能退出游戏或者清空对应的缓存才能处理。但是更好的方案是把_load2方法中这段代码
 if (task.options.cache !== false)
                Loader._cacheRes(formattedUrl, content, typeId, main);
  if (content != null && assetLoader.postLoad != null) {
      task.result = content;
      return assetLoader.postLoad(task, content).then(() => {
          task.progress.update(-1, 1);
          task.onComplete.invoke(content);
          return content;
      });
  }
改为:
if (content != null && assetLoader.postLoad != null) {
        
      if (task.options.cache !== false)
                Loader._cacheRes(formattedUrl, content, typeId, main);
      
      task.result = content;
      return assetLoader.postLoad(task, content).then(() => {
          task.progress.update(-1, 1);
          task.onComplete.invoke(content);
          return content;
      });
  }
即:当内容为空时不缓存该资源。
Metadata
Metadata
Assignees
Labels
No labels