Prevented SpriteControl from crashing when resizing AnimatedSprite2D nodes that lack a frame texture by guarding the resize logic and logging a warning instead.

This commit is contained in:
Adrien Ufferte
2025-12-16 11:10:33 +01:00
parent 4bd89547fa
commit 95e3c6fa9a
+5 -2
View File
@@ -38,8 +38,11 @@ func _resize_sprites() -> void:
var animated_sprite_2d: AnimatedSprite2D = sprite var animated_sprite_2d: AnimatedSprite2D = sprite
if animated_sprite_2d.sprite_frames: if animated_sprite_2d.sprite_frames:
var texture: Texture2D = animated_sprite_2d.sprite_frames.get_frame_texture(animated_sprite_2d.animation, animated_sprite_2d.frame) var texture: Texture2D = animated_sprite_2d.sprite_frames.get_frame_texture(animated_sprite_2d.animation, animated_sprite_2d.frame)
animated_sprite_2d.centered = false if texture:
animated_sprite_2d.scale = size / texture.get_size() animated_sprite_2d.centered = false
animated_sprite_2d.scale = size / texture.get_size()
else:
Log.warn("SpriteControl: Missing texture for animation '%s' frame %d on %s" % [animated_sprite_2d.animation, animated_sprite_2d.frame, animated_sprite_2d.name])
func _ready() -> void: func _ready() -> void: