用 CocosCreate 加载 resources 的 prefab, 加载完成后初始化, 放在场景里, 但prefab里的资源还在加载, 有一段时间是空白, 如何可以加载的时候一并加载
同问,一直很困扰
把资源直接拖到prefab上让其变成静态引用,你在一个动态加载的prefab上绑定的ts里面去动态加载的图片,鬼知道什么时候能完成
预加载资源,资源加载完毕加载预制体
暂时解决了,监听预制体上的所有spriteFrame的load事件,都加载完毕时即说明prefab加载完成, 下面是官方文档:
/**
!#en If a loading scene (or prefab) is marked as asyncLoadAssets, all the textures of the SpriteFrame which
associated by user’s custom Components in the scene, will not preload automatically.
These textures will be load when Sprite component is going to render the SpriteFrames.
You can call this method if you want to load the texture early.
!#zh 当加载中的场景或 Prefab 被标记为 asyncLoadAssets 时,用户在场景中由自定义组件关联到的所有 SpriteFrame 的贴图都不会被提前加载。
只有当 Sprite 组件要渲染这些 SpriteFrame 时,才会检查贴图是否加载。如果你希望加载过程提前,你可以手工调用这个方法。
@example
```js
if (spriteFrame.textureLoaded()) {
this._onSpriteFrameLoaded();
}
else {
spriteFrame.once('load', this._onSpriteFrameLoaded, this);
spriteFrame.ensureLoadTexture();
}
```
*/
ensureLoadTexture(): void;