[3.3.2]TypeError: Cannot read properties of null (reading 'height') of SpriteAtlas Sp

TypeError: Cannot read properties of null (reading ‘height’)
at ReelItemAni.MakePixelPerfect (ReelItemAni.ts:141:110)
at ReelItemAni.update (ReelItemAni.ts:45:37)
at component-scheduler.ts:281:35
at ReusableInvoker._invoke (component-scheduler.ts:233:13)
at ReusableInvoker.invoke (component-scheduler.ts:195:14)
at ComponentScheduler.updatePhase (component-scheduler.ts:480:28)
at Director.tick (director.ts:746:37)
at callback (game.ts:734:26)

After i run the program this error appears. The “height” property is “null” in this method:

public MakePixelPerfect(){
this.sprite.sizeMode = 0;
this.sprite.node.getComponent(UITransform).width = this.nWidth;
this.sprite.node.getComponent(UITransform).height = Math.floor(this.nWidth * this.sprite.spriteFrame.height / this.sprite.spriteFrame.width);
}

I don’t know why. Please help me. Thanks!

Only the code can not see the problem, you can show your demo for people who see it to help you.

1 Like

I can’t send video, so i send some picture about my error:

.

I don’t know where this error is coming from, this method or file .plist “iconterran”
Can anyone help me with the answer?Thanks!

You can breakpoint here to see if the spriteFrame is empty.

1 Like