引擎版本:3.7.4
是否必现:否,多数能正常显示,但是多次测试会很容易测出crash
我是远程加载spine,相关应用代码:
private async _applySpineData(frame:sp.SkeletonData){
if(!isValid(this)){
return;
}
let comp = this.compSkel
if(frame){
comp.skeletonData = frame;
const _skeleton = comp._skeleton
await hyz._schedule.waitForTime(0);//等待一帧,不然有时候不生效
if(!isValid(comp)){
return
}
const animationNames = _skeleton.data.animations.map((item)=>item.name)
if(comp.animation){
comp.setAnimation(0,comp.animation,comp.loop)
}else{
const aniName = animationNames[0]??"animation"
comp.setAnimation(0,aniName,comp.loop)
}
comp.premultipliedAlpha = this.premultipliedAlpha
if(this.sizeLimit){
const uiTrans = this.node.getComponent(UITransform);
if(uiTrans){
let _scale = Math.min(this.limitSize.width/uiTrans.contentSize.width,
this.limitSize.height/uiTrans.contentSize.height)
this.node.setScale(v3(_scale,_scale,1));
}
}
}
}
其他线索:关注这一行:await hyz._schedule.waitForTime(0);
如果不添加这一行,则会导致setAnimation失败,但不会crash,添加了这一行,大多数能成功播放动画,但是偶尔会crash
求引擎组关注 @dumganhar


