v4.2.stable.official [46dc27791]
Godot v4.2.stable - macOS 14.2.0 - Vulkan (Forward+) - integrated Apple M1 - Apple M1 (8 Threads)
Question
I’m using a RichTextLabel for dialogue system in my project. One part of the message is using a highlight, that is, the area behind text is filled with solid color.
How can I make this highlight blink? Not the text itself, only the highlight.
However, looking at the CharFXTransform class documentation, it doesn’t look like you can access background colour of a character and change this. Maybe you could directly draw onto it? Or use an outline effect instead?
Yes, I can’t access the “highlight” property, this is the problem. “Outline” etc are all accessible but “highlight” isn’t.
I tried making custom effects, but didn’t manage to make it work. Unofficial instructions (there are some on youtube and so on) all deal with Godot 3, and official Help is not going into details that are necessary for making it work.
For example, if I want to install the custom effects from code instead of assigning it in the Inspector, the instructions just say something like: just install it, it’s very practical! I’m supposed to do it like this:
Where does this code go? In “ready” of the RichTextLabel? I tried everything I can think of but just can’t make it work.
The highlight (background color/bgcolor) isn’t part of the text itself, but is drawn as a rectangle by RichTextLabel itself. I don’t think there’s a way to access it from RichTextEffect, so you have to create a custom RichTextEffect that replicates bgcolor’s functionality while making it blink.
Reading the source code implementation, you should be able to call _install_effect(preload("res://path/to/custom_effect.gd")) in a RichTextLabel script’s _ready() function.
[quote=“Calinou, post:4, topic:38042”]
Reading the source code implementation, you should be able to call _install_effect(preload("res://path/to/custom_effect.gd")) in a RichTextLabel script’s _ready() function.[/quote]
Thank you for looking into this, I really appreciate it!
I tried adding the code from your example by copy pasting it (and adjusting the file path), it doesn’t work because it has an underscore. So I tried other variations. None of these worked:
(sorry had to separate this into two posts because the forum doesn’t allow new users to post more than one multimedia something per post)
But even adding it in the Inspector is a bit confusing. While adding it to the array of effects, if I use QuickLoad it doesn’t show up at all. Where is it? So I have to select it from the menu and then it works. Here is a screen capture showing it in action: