Godot Version
Godot 4.5
Question
Hey,
I need to grab one vertical column of pixels from a PNG file and use it as the texture for a Sprite2D in Godot 4.5 at runtime.
Tried Image.load(), ImageTexture.get_data(), and load_png_from_buffer(), but I only get a transparent pixel.
Is there a way to do this in GDScript?
Thanks!
1 Like
zigg3c
2
You could make an atlast texture:

var atlas_texture := AtlasTexture.new()
atlas_texture.atlas = load("res://icon.svg")
atlas_texture.region = Rect2(14.0, 38.5, 43.0, 42.0) # Right eye
sprite_2d.texture = atlas_texture
1 Like
Works flawlessly, thank you
1 Like
system
Closed
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.