开启动态合图:
macro.CLEANUP_IMAGE_CACHE = false;
dynamicAtlasManager.enabled = true;
远程图片资源加载 ImageAsset -> Texture2d -> SpriteFrame 后释放报错
export class ImageAssetEx {
private _ref: number = 0;
constructor(
public imageAsset: ImageAsset,
public texture: Texture2D,
public spriteFrame: SpriteFrame
) {
}
get refCount(): number {
return this._ref;
}
addRef(): ImageAssetEx {
this._ref++;
this.spriteFrame.addRef();
this.texture.addRef();
this.imageAsset.addRef();
return this;
}
decRef(autoRelease: boolean= false): ImageAssetEx {
--this._ref;
this.spriteFrame.decRef(autoRelease);
this.texture.decRef(autoRelease);
this.imageAsset.decRef(autoRelease);
if(this._ref === 0) {
//下面这句话报错
assetManager.releaseAsset(this.spriteFrame)
assetManager.releaseAsset(this.texture)
assetManager.releaseAsset(this.imageAsset)
}
return this;
}
}