Attention: This is not actively developed anymore. See thispost for further details!
I saw that some people want a multi-colored text in UMG, and I wanted that aswell, so I decided to pack it into a plugin. The RichTextBox is already available in the engine, but it is locked with UCLASS(Experimental). I copy/pasted those files inside new source files, removed the experimental tag, and packed it for a plugin, which works great.
How it looks in UMG:
It supports all colors (uses hex color codes + opacity) and all font styles the selected font has. How the formatting works:
It uses <span> for it’s formatting. The hex codes are built the following way: #RRGGBBAA (red - green - blue - alpha / opacity, ranging from 0 to F). Examples for formatting:
<span color="#ffffffff">This is a white text.</>
<span color="#ff0000ff">This is a red text.</>
<span color="#ffff0066">This is a yellow text with 50% opacity.</>
<span style="bold">This is a bold text.</>
<span style="italic">This is an italic text.</>
<span style="bold italic">This is a bold italic text.</>
<span color="#0000ffff" style="bold">This is a blue bold text.</>
The font styles such as “bold” or “italic” must have the same name in your font you put inside the TextBox.
**Download: **Click here Installation: Put the folder UmgRichTextBox inside the downloaded zip into your project’s Plugins folder (if thats not existing, create it!).
Hope you like this plugin (even though my own work is 0% :D)!
It didn’t do it, though. When I press Launch or try packaging the game it wont show the RichText panel. It does show it when I Play the map from the editor. I have been trying to go through the other threads where people have had similar problems but a lot them seem to be about the project not being C++ project.
My project is C++ project. Using C++ project instead of BP one was one of the suggestions on other forums, too. Another one was that I should put it in the Game folder instead of Engine folder for plugins, which I had also already done.
Hey I have this working, but I’m trying to add a method to update the font after it’s been created. From testing I can see that the URIchTextBox::Font is updated, but I can’t get the widget to rebuild to display it. Heres the function I’m trying to use:
It seems like SynchroniseProperties() or RebuildWidget() should be updating the font, but it’s like the decorators only ever use the first font they’re initialised with. I’ve also noticed in the BP editor that the updated font doesn’t apply until you hit ‘compile’, which I guess rebuilds the widget.
URichTextBox::Font should do nothing since that is the class. I don’t have my source here now, but I should have a variable for the Slate widget, the var is mostly named MyTextBox or something. Grab that variable and to ->SetFont(…); which should update the font automaticially… About the SynchronizeProperties(): you can’t call it - it’s only called by the editor when you change a parameter. Same with RebuildWidget(), which is called when you compile the widget BP. So what you should do:
// I already wrote stuff here
MyTextBox->SetFont(MyFontVar); //lookup the real var Name since i don't have the source right now..
Thanks so much for this! Fun fact, you can actually use OTHER RTF stuff you didn’t mention as well.
<span size="36">This would be 36pt font</>
I wonder if the RichTextBlock has image-inserting markup, for QTE button images or Mario-Galaxy style icon-in-objective “If I only had a [star piece image]”…
EDIT: the docs mention in passing that Slate’s RTF block does support inline images (and widgets, actually) but I have no idea what the markup on that is. I assume <span image=“xyz”> since that’s how it usually works in span formatting but IDK what the “name” for an image is in the engine. File path? Variable name?
Lately I have had a problem where when loading the project I get the following error message:
Error /Game/UI/DialogueHUD : Can't find file for asset. /Script/UmgRichTextBox
Error /Game/UI/CharacterCreation/CharacterCreationUI : Can't find file for asset. /Script/UmgRichTextBox
Info Failed to load /Game/Blueprints/CharacterCreationBP.CharacterCreationBP_C Referenced by WidgetTree
Info Failed to load /Game/Blueprints/CharacterCreationBP.CharacterCreationBP_C Referenced by BorderSlot_0
Info Failed to load /Game/Blueprints/CharacterCreationBP.CharacterCreationBP_C Referenced by EdGraphPin_612
Info Failed to load /Game/Blueprints/CharacterCreationBP.CharacterCreationBP_C Referenced by K2Node_CallFunction_37
Info Failed to load /Game/Blueprints/CharacterCreationBP.CharacterCreationBP_C Referenced by EdGraphPin_616
Info Failed to load /Script/UmgRichTextBox.RichTextBox Referenced by BorderSlot_0
Warning CreateExport: Failed to load Outer for resource 'DefaultDecorator': RichTextBox /Game/UI/DialogueHUD.DialogueHUD:WidgetTree.InfoText
Warning CreateExport: Failed to load Outer for resource 'DefaultDecorator': RichTextBox /Game/UI/DialogueHUD.DialogueHUD_C:WidgetTree.InfoText
The two RichTextBoxes referenced by the message log seem to delete themselves on load, but some of them seem to load just fine which is weird.