How to get subregion of texture using code?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Diet Estus

Is it possible to carve up a Texture using code in Godot 3.0?

I have a spritesheet that I am trying to carve up manually. I want to load it as a texture and then carve it up into subtextures.

var main_texture = load("res://main_texture.png")
var subtexture1 = ...

Couldn’t find the answer in the documentation on Textures.

:bust_in_silhouette: Reply From: SIsilicon

You can try using an atlas texture.

var tex_subregion =

All you need to do is to give it the texture


And the region of your choice and you are good to go.

tex_subregion.set_region('a rect2')