0 votes

Example: "The sky is blue"
How to change the color of the word "blue"?

asked Sep 26, 2019 in Engine by DarlesLSF (167 points)

2 Answers

+2 votes
Best answer

With a RichTextLabel node you can use BBCode formatting.

First enable the "Bb Code" property in the inspector, then enter the code in the BBCode text field.

For your example the code would be: The sky is [color=#4ab3ff]blue
To stop using a color use [/color].

Note that you can simply test colors with the modulate property and copy the color code. Or just use one of the built in colors like [color=blue].

Of course you could do this also from script:

$RichTextLabel.bbcode_text = "The sky is [color=#4ab3ff]blue[/color]"

There is also a way to do this without BBCode, but I think this works only from script:

$RichTextLabel.add_text("The sky is ")
answered Sep 26, 2019 by Adam_S (1,191 points)
selected Sep 26, 2019 by DarlesLSF

Thx alot dude, u solve my problems haha

0 votes

Using a RichTextLabel, set bbcode_enabled to true, then bbcode_text you can do: The sky is [color=blue]blue[/color]

You can see a full list of colors here: https://docs.godotengine.org/en/3.1/tutorials/gui/bbcode_in_richtextlabel.html#built-in-color-names

answered Sep 26, 2019 by Eric Ellingson (1,581 points)
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.