Is it possible to use a atlas texture within RTL's BBCode?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By wombatTurkey
:warning: Old Version Published before Godot 3 was released.

I know we can use the [img]res://icon.png[/img]

However, I am writing a Emoji Parser for chat and was curious if we could somehow use a spritesheet within the [img] tags instead of using hundreds of individual images. Any idea how to do this? Thanks in advance

Waaaaaaaaaait a minute, you can add images to a rich text label? Holy mother of jesus.

mateusak | 2017-01-03 04:19

@mateusak what do you mean?

wombatTurkey | 2017-01-03 14:34

Just for curiosity tried this on a RTL and worked:

var texture = preload("res://icon.png")
var subimage = texture.get_data().get_rect(Rect2(10,10,10,10))
var subtexture = ImageTexture.new()

subtexture.create_from_image(subimage)	
subtexture.set_path("res://virtualpath/subtexture.png")

add_text(str("subimage: "))
append_bbcode(str("[img]",subtexture.get_path(),"[/img]"))

This code on RTL ready will cut a bit of icon file and create a new image from the texture then crop the image to make a new resource

So, it seems that will work, you need to find a good way to organize your “virtual resources”, and maybe get rid of them when not used too.


Made this with zero knowledge on the subject so maybe there is a better/direct way to get the final resource, look at Texture, TextureImage, Image and related classes.
Try and share your findings :slight_smile:

eons | 2017-01-03 16:31