cocos creator 版本3.8.4
安卓sdk 29
用摄像机截图功能 RenderTexture
给sp.Skeleton 赋值setSlotTexture 时安卓会闪退
发现 setSlotTexture(slotName: string, tex2d: Texture2D, createNew?: boolean): void;
传入参数是Texture2D类型的 后续把SpriteFrame转成Texture2D还是报错
Fatal signal 11 (SIGSEGV), code 0 (SI_USER) in tid 3045 (Thread-2), pid 3025
pid: 3025, tid: 3045, name: Thread-2 >>> <<<
有大神遇到过同样问题吗
protected async update(dt: number) {
if (this.renderCommand.length <= 0) {
return;
}
const command = this.renderCommand[0];
if (command.status == 0) {
// 纹理初始化
command.status = 1;
const texture = new RenderTexture();
if (command.flipUV) {
this.cardTemplate.node.setScale(1, -1, 1);
} else {
this.cardTemplate.node.setScale(1, 1, 1);
}
const transform = this.node.getComponent(UITransform);
texture.reset({ width: transform.width, height: transform.height });
this.cameraRender.targetTexture = texture;
if (command.cardInfo) {
const cardInfo = DataMgr.getData('card_config', command.cardInfo.uid);
if (cardInfo.kind == command.cardInfo.kind)
await this.cardTemplate.setCardInfo(command.cardInfo);
else
await this.cardTemplate.setCardInfo(cardInfo);
} else {
await this.cardTemplate.setCardId(command.cardId, command.skin_id);
}
command.status = 2;
} else if (command.status == 2) {
// 纹理渲染
//const spriteFrame = new SpriteFrame();
//spriteFrame.texture = this.cameraRender.targetTexture;
var width = this.node.getComponent(UITransform).width;
var height = this.node.getComponent(UITransform).height;
var _buffer = this.cameraRender.targetTexture.readPixels();
let img = new ImageAsset();
img.reset({
_data: _buffer,
width: width,
height: height,
format: Texture2D.PixelFormat.RGBA8888,
_compressed: false
});
let texture = new Texture2D();
texture.image = img;
Helper.CCLOG("输出!======>", texture)
command.handler(texture);
// this.cameraRender.targetTexture = this.defalutTexture;
this.renderCommand.shift();
}
}
问题找到了 Texture2D持久化
请问是怎么解决的?
使用对象池 缓存起来