0 votes

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

in Engine by (43 points)

1 Answer

0 votes

https://docs.godotengine.org/en/stable/classes/class_richtextlabel.html

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)
by (1,213 points)

Does this need to be written in a richtextlabel script?

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.