-
Creator 版本:3.8.6
-
目标平台:Windows
-
重现方式:详细查看以下代码
-
首个报错:
-
之前哪个版本是正常的:
-
手机型号:
-
手机浏览器:
-
编辑器操作系统:
-
重现概率:100%
ReleaseAssetSpriteFrame(spriteFrame:SpriteFrame){
if(spriteFrame.refCount<=0){
let texture:Texture2D=null;
// 图片纹理是否已合图
console.log("spriteFrame.packable:"+spriteFrame.packable);
console.log("spriteFrame.original:"+spriteFrame.original);
if (spriteFrame.packable) {
if(spriteFrame.original){
texture=spriteFrame.original._texture as Texture2D;
}else{
texture=spriteFrame.texture as Texture2D;
}
}else{
texture=spriteFrame.texture as Texture2D;
}
const image=texture.image;
const assetUuid=image.uuid;
texture.decRef();
spriteFrame.texture=null;
// 释放spriteFrame资源
this._assetsCache[assetUuid]=null;
assetManager.releaseAsset(spriteFrame);
if(texture.refCount<=0){
image.decRef();
texture.image=null;
assetManager.releaseAsset(texture);
if(image.refCount<=0){
assetManager.releaseAsset(image);
}
}
}
}
11:52:48 [DEBUG]: JS: spriteFrame.packable:true
11:52:48 [DEBUG]: JS: spriteFrame.original:null
11:52:48 [DEBUG]: JS: spriteFrame.packable:true
11:52:48 [DEBUG]: JS: spriteFrame.original:null
11:52:48 [DEBUG]: JS: spriteFrame.packable:true
11:52:48 [DEBUG]: JS: spriteFrame.original:null
11:52:48 [DEBUG]: JS: spriteFrame.packable:true
11:52:48 [DEBUG]: JS: spriteFrame.original:null
我在调试的时候发现spriteFrame.packable为true,但是spriteFrame.original却为null,导致当时取spriteFrame.original._texture时直接报错,图片比较小的时候是这样,图片比较大时,比如几M的图片,规格超过合图限制时就正常spriteFrame.packable为false,我试过强制设置自动合图为false,但还是这样,请问这是什么情况导致的?
windows 模拟器还是桌面浏览器,是预览还是构建打包后?
是选择windows构建后运行的
根据我残存的记忆,合包后的纹理不就是 spriteFrame.texture吗?
我之前看别人的加载图片的帖子里,说是没有合包的图片纹理是在spriteFrame.texture里,合包后在spriteFrame.original._texture里,我现在碰到的问题是明明spriteFrame.packable为true,是合包的状态,但是spriteFrame.original却为null,导致无法获取spriteFrame.original._texture
检查是否开启了动态合图
我看官方文档说是目前在小游戏和原生平台上默认会禁用动态合图,我的构建发布平台是Windows,我刚刚调试了一下
09:55:23 [DEBUG]: JS: macro.CLEANUP_IMAGE_CACHE:true
09:55:23 [DEBUG]: JS: DynamicAtlasManager.instance.enabled:false
这样应当是没开启动态合图
现在我就是这个问题,讲道理在没开启动态合图的情况下,应当spriteFrame.packable为false才对,但是现在spriteFrame.packable却为true,当然就算是bug导致spriteFrame.packable没走动态合图配置才为true,那在这种情况下spriteFrame.original._texture就应当是有数据的,结果却为null。
我不知道是不是现在动态合图的配置没用了?还是说改策略了?