0 votes

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

in Engine by (171 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 ")
$RichTextLabel.push_color(Color.blue)
$RichTextLabel.add_text("blue")
by (1,457 points)
selected by

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

by (1,605 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.
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.