[Discontinued] UMG Rich Text Box

Attention: This is not actively developed anymore. See thispost for further details!

Hey guys,
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)!

2 Likes

Wow, I was needing this just yesterday.

It looks very promising, Iā€™m going to give it a go and tell you how it goes.

Thank you so much dear sir :slight_smile:

EDIT: I wonder if I can format this using Blueprints only.

It has a ā€œSet Textā€ blueprint node, so setting the content with blueprints is possible, and it should also parse it instantly (the best thing there is the Format Text).

Working instantly as planned. Easily setup, easily used. Thank you so much :slight_smile:

That looks cool!!

This is awesome, Thanks

I tried doing this same thing but it doesnā€™t seem to recognize <span> but instead makes an error message about slate styles.

In my plugin or did you try that on your own?

Your plugin. Thanks a bunch, by the way :slight_smile:

I got it working in the editor. I guess I needed to restart the editor for the it work properly or I had goofed something and not changed the text field to richtext after all.

But it doesnā€™t seem to get packaged which is what I am trying to trouble shoot on other threads (plugins not packaging seems to be an issue that has been happening with other people).

You need to go into your ProjectName.Build.cs and uncomment the line with Slate and SlateCore. If you canā€™t find the file, add a empty class to the project so it generates it.

There was no commented out line with Slate or SlateCore but I assume it should be


PrivateDependencyModuleNames.AddRange(new string] { "Slate", "SlateCore" });

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.

Hm, thats strangeā€¦ Try creating a C++ project and adding the plugin, but my project I tested it on is also a blueprint-only project and it works fineā€¦

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.

Okay, adding ā€œUmgRichTextBoxā€ as a dependency module seemed to do the trick.

No packaging problems here on a full blueprint project.

Just so you know :wink:

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:



void URichTextBox::SetFont(FSlateFontInfo InFontInfo)
{
	URichTextBox::Font = InFontInfo;
	URichTextBox::SynchronizeProperties();
	URichTextBox::RebuildWidget();
}


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.

Can anyone offer any direction on this?

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:



URichTextBox::SynchronizeProperties()
{
  // I already wrote stuff here
  MyTextBox->SetFont(MyFontVar); //lookup the real var Name since i don't have the source right now..
}


Have a nice day :slight_smile:

Hey over here :slight_smile:

  • SOLVED -
    Is there an easy way to update my project to 4.12 while keeping your Rich Text Box plugin?

Thank in advance for any answer.

Have a great day!

EDIT: I easily found the way to make it work in 4.12. However it stopped working in packaged version.

Following this made it work:

Thank you for going back to write how you solved it.

And thank you for your plugin once again! :slight_smile:

Thanks so much for this! Fun fact, you can actually use OTHER RTF stuff you didnā€™t mention as well.

e.g.


<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.