How to add a picture to the text

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

I think everything is clear. Can I add a icon to a label or richtextlabel

:bust_in_silhouette: Reply From: Andrea

add_image() would do the job, just remember that it requires a texture and not a picture

var t=Texture.new()
t=load("res://icon.png")
add_image(t,10,10)

Does this need to be written in a richtextlabel script?

start123 | 2020-05-26 17:07

either that or you reference another richtextlabel object, like richtextlabel.add_image(t,10,10)
As many other coding langues, in Godot all the functions (methods) are linked to an object (nodes): you can refer to any node (and call its related methods) from every piece of script, you just have to specify it before the “.
If you dont specify it, Godot assumes you are referencing the same node the script is attached to

Andrea | 2020-05-26 21:31