3.4.1 bug resources.load ScriptFrame 抓不到檔案 [已解決] 要用 SpriteFrameAsset

3.4.1

resources.load ScriptFrame 抓不到檔案
但是讀取資料夾resources.loadDir是可以的

  • Creator 版本: 3.4.1

  • 目标平台:win chrome浏览器 開發網頁

  • 重现方式:

  1. 设置Init.ts / 丢到场景里
  2. resources/jpgfile1.jpg 放张图片
  3. 运行预览
import { _decorator, Component, Node, resources, SpriteFrame, Sprite } from 'cc'
const { ccclass, property } = _decorator

@ccclass('Init')
export class Init extends Component {
  start() {
    resources.load('jpgfile1', SpriteFrame, function (err, spriteFrame) {
      console.log('err', err)
      console.log('spriteFrame', spriteFrame)
    })
  }
}
  • 首个报错:
err Error: Bundle resources doesn't contain jpgfile1
    at _loop (index.js:93707:25)
    at parse (index.js:93784:18)
    at Pipeline.sync (index.js:92392:26)
    at preprocess (index.js:92711:53)
    at Pipeline._flow (index.js:92447:11)
    at Pipeline.async (index.js:92440:16)
    at AssetManager.loadAny (index.js:86807:20)
    at Bundle.load (index.js:87290:33)
    at Init.start (Init.js:26:21)
    at index.js:150321:16
  • 编辑器操作系统: windows
  • 重现概率:100%

找到解决方法了
好像要用 SpriteFrameAsset 才可以
但是文档没有说明 请再更新

resources.load('image', SpriteFrameAsset, function (err, spriteFrame) {

      if (err) {

        console.error(err)

      }

    })

周末都不休息的吗,这么卷:sneezing_face:

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。