User Tag List

Page 1 of 2 12 LastLast
Results 1 to 40 of 60

Thread: UMG Rich Text Box

  1. #1
    0

    UMG Rich Text Box

    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:
    Code:
    <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% )!

  2. #2
    0
    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

    EDIT: I wonder if I can format this using Blueprints only.
    Last edited by Yun-Kun; 03-27-2016 at 07:26 AM.

  3. #3
    0
    Quote Originally Posted by Yun-Kun View Post
    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).

  4. #4
    0
    Working instantly as planned. Easily setup, easily used. Thank you so much
    Attached Images Attached Images   
    Last edited by Yun-Kun; 03-27-2016 at 08:39 AM.

  5. #5

  6. #6
    0
    This is awesome, Thanks

  7. #7
    0
    I tried doing this same thing but it doesn't seem to recognize <span> but instead makes an error message about slate styles.

  8. #8
    0
    Quote Originally Posted by Au-heppa View Post
    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?

  9. #9
    0
    Your plugin. Thanks a bunch, by the way

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

  10. #10
    0
    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.

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

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

  12. #12
    0
    Quote Originally Posted by Au-heppa View Post
    There was no commented out line with Slate or SlateCore but I assume it should be

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

  13. #13
    0
    Quote Originally Posted by iUltimateLP View Post
    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.

  14. #14
    0
    Okay, adding "UmgRichTextBox" as a dependency module seemed to do the trick.

  15. #15
    1
    No packaging problems here on a full blueprint project.

    Just so you know

  16. #16
    0
    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:

    Code:
    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?
    Twitter: @GSGBen

  17. #17
    0
    Quote Originally Posted by goldensyrupgames View Post
    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:

    Code:
    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:
    Code:
    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

  18. #18
    0
    Hey over here

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

    Quote Originally Posted by Au-heppa View Post
    Okay, adding "UmgRichTextBox" as a dependency module seemed to do the trick.
    Thank you for going back to write how you solved it.

    And thank you for your plugin once again!
    Last edited by Yun-Kun; 06-11-2016 at 10:40 AM.

  19. #19
    0
    Thanks so much for this! Fun fact, you can actually use OTHER RTF stuff you didn't mention as well.

    e.g.
    Code:
    <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?
    Last edited by RhythmScript; 06-11-2016 at 04:40 PM.

  20. #20
    0
    Lately I have had a problem where when loading the project I get the following error message:

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

  21. #21
    0
    Hi!

    Thanks for making this plugin.
    It worked perfectly in the editor (4.11). However, I couldn't get it to work in any kind of packaged build (it is not appearing at all, no error messages).
    The project is c++.
    I already Generated Visual Studio project files and built it from Visual Studio.
    Right after I dropped the plugin in the project's folder and opened the uproject, it asked me to build the plugin and I did - it worked fine.

    What can I do to make it work?

    Thanks!

  22. #22
    0
    Any chance you can compile this for 4.12?

  23. #23
    0
    Are there any news on this? I can't seem to get it to work on 4.12.5 - it shows the text as regular text, including the markup.

  24. #24
    0
    Any idea how you make 'Span' work in C++ and not via UMG? E.g, the following doesn't work due to the extra pair of quoteS:

    Code:
    	FFormatNamedArguments TextArgs;
    	TextArgs.Add(TEXT("SpeakerCol"), FText::FromString(TEXT("<span color="#ff0000ff">")));
    Trying to create the text string in code.. anybody?

    EDIT: Got it to compile by adding backslashes before the extra quotes. However, adding markup doesn't work it seems :/ Example:

    EDIT: ARGH 2.0 - got it working, had the formatting wrong. Final result:

    Code:
    	UBZGame_RichTextBlock* NewRichText = NewObject<UBZGame_RichTextBlock>(this);
    	ASSERTV(NewRichText != nullptr, TEXT("Unable to create new Rich Text Block"));
    
    	// Can be static const
    	FFormatNamedArguments TextArgs;
    	TextArgs.Add(TEXT("PlyBreak"), FText::FromString(TEXT(": ")));
    	TextArgs.Add(TEXT("PlyrColour"), FText::FromString(TEXT("<span color=\"#ff0000ff\">")));
    	TextArgs.Add(TEXT("MsgColour"), FText::FromString(TEXT("<span color=\"#ff00ffff\">")));
    	TextArgs.Add(TEXT("FormatEnd"), FText::FromString(TEXT("</>")));
    	TextArgs.Add(TEXT("PlayerName"), FText::FromString(Message.Sender->PlayerName));
    	TextArgs.Add(TEXT("Msg"), FText::FromString(Message.ChatMessage));
    	
    	// Build 'marked up' message
    	const FText FinalText = FText::Format(LOCTEXT("FinalText_Key", "{PlyrColour}{Msg}{FormatEnd}"), TextArgs);
    
    	NewRichText->SetText(FinalText);
    Last edited by TheJamsh; 07-26-2016 at 02:06 PM.

  25. #25
    0
    Quote Originally Posted by TheJamsh View Post
    Any idea how you make 'Span' work in C++ and not via UMG? E.g, the following doesn't work due to the extra pair of quoteS:

    Code:
        FFormatNamedArguments TextArgs;
        TextArgs.Add(TEXT("SpeakerCol"), FText::FromString(TEXT("<span color="#ff0000ff">")));
    Trying to create the text string in code.. anybody?
    Try using
    Code:
    FText::FromString(TEXT("<span color='#ff0000ff'>"));
    ,
    that should work!
    To anybody else, I'll work out an update for 4.12.5 and post it here soon!

  26. #26
    0
    There are some problems with this plugin like it is: I installed it, everything worked, but on editor restart, the editor shows errors that Rich Text Box script is not found. When I went to my HUD blueprint - all text was gone! Also, as it was noted above, plugin is not displayed in the packaged build (I actually could see errors in the logs while packaging that something related to URichTextBox is not found). I tried to add a reference in build.cs file, but it did not help, in fact, I was getting other errors, and on editor restart it could not open my project at all...

    So, this is how I finally made it work (4.13 preview 2, it also works in a packaged build, and on editor restart):
    (My base project is C++)
    1. Do not use the plugin like it is. Instead, create a new C++ class RichTextBox inherited from Widget.
    2. Copy everything from plugin's RichTextBox.h/.cpp to our RichTextBox.h/.cpp
    3. Compile, Enjoy

  27. #27
    0
    The type should be set to Runtime in .uplugin otherwise it will break in packaged builds.

    Name:  runtime.png
Views: 3632
Size:  5.4 KB

  28. #28
    0
    Quote Originally Posted by Flash7 View Post
    There are some problems with this plugin like it is: I installed it, everything worked, but on editor restart, the editor shows errors that Rich Text Box script is not found. When I went to my HUD blueprint - all text was gone! Also, as it was noted above, plugin is not displayed in the packaged build (I actually could see errors in the logs while packaging that something related to URichTextBox is not found). I tried to add a reference in build.cs file, but it did not help, in fact, I was getting other errors, and on editor restart it could not open my project at all...

    So, this is how I finally made it work (4.13 preview 2, it also works in a packaged build, and on editor restart):
    (My base project is C++)
    1. Do not use the plugin like it is. Instead, create a new C++ class RichTextBox inherited from Widget.
    2. Copy everything from plugin's RichTextBox.h/.cpp to our RichTextBox.h/.cpp
    3. Compile, Enjoy
    It's not specifically due the plugin it self. I had issue with the WebBrowser plug-in for exactly the same issue. I raise a #issue for this : https://answers.unrealengine.com/questions/375480/umg-webbrowser-failed-to-load.html

  29. #29
    0
    When I first seen this thread I thought this was exactly what I was looking for. I got it added to my project and it works fine.
    When I started looking into the RichTextBox code I first thought adding images would be as simple as adding an ImageDecorator to the list of Decorators for the widget.
    Unfortunately it seems a little more involved and I can't quite wrap my head around how to add ImageDecorator support to the RichTextBox class.

    Anyone have any thoughts?

  30. #30
    0
    Anyone had any more progress with this, regarding images in RichTextBoxes?

  31. #31
    0
    Quote Originally Posted by iUltimateLP View Post
    Try using
    Code:
    FText::FromString(TEXT("<span color='#ff0000ff'>"));
    ,
    that should work!
    To anybody else, I'll work out an update for 4.12.5 and post it here soon!
    Did you ever make a 4.12.5 version?

  32. #32
    0
    Hello!

    Can you please clarify the license of this plugin?
    Is this distributed under a complete free license, or has any restrictions?

    Thank you.

  33. #33
    0
    Quote Originally Posted by benhumphreys View Post
    Anyone had any more progress with this, regarding images in RichTextBoxes?
    I'll try to implement images in the boxes, and report it here!

    Quote Originally Posted by DrinkThisPotion View Post
    Did you ever make a 4.12.5 version?
    Unfortunatelly not, due to time issues on my side, but I'll catch up and update this to 4.14.2 somewhere around next week.

    Quote Originally Posted by teddbroiler View Post
    Hello!

    Can you please clarify the license of this plugin?
    Is this distributed under a complete free license, or has any restrictions?

    Thank you.
    It is completly free, you can use it for whatever you prefer

  34. #34
    0
    Hey, thanks for the plugin @iUltimateLP!

    I've made a few fixes here:
    RichTextBox.h
    RichTextBox.cpp
    - Added shadows back in (though they don't seem to work with <span> text)
    - Fixed depreciation errors
    - Reordered/renamed some things to make it more similar to the normal TextBlock

    Also as @Flash7 pointed out, you can just put these files directly into your project and change the class API/header to your project, much easier than dealing with a plugin. (I couldn't get the plugin working)

    Edit: I looked deeper into the RichText code and it seems to only support these tags: Span, Size, Style, Color, and Font. So sorry for those who wanted inline images, looks like they're not supported in any way.
    Also it seems like RichTextBlock doesn't support changing color at runtime. Any ideas on how to solve this?
    Last edited by Juice-Tin; 01-20-2017 at 06:47 PM.

  35. #35
    0
    Quote Originally Posted by Juice-Tin View Post
    Hey, thanks for the plugin @iUltimateLP!

    I've made a few fixes here:
    RichTextBox.h
    RichTextBox.cpp
    - Added shadows back in (though they don't seem to work with <span> text)
    - Fixed depreciation errors
    - Reordered/renamed some things to make it more similar to the normal TextBlock

    Also as @Flash7 pointed out, you can just put these files directly into your project and change the class API/header to your project, much easier than dealing with a plugin. (I couldn't get the plugin working)

    Anyone have ideas on how to create new lines? It seems to ignore \n and <br>.

    Edit: I looked deeper into the RichText code and it seems to only support these tags: Span, Size, Style, Color, and Font. So sorry for those who wanted inline images, looks like they're not supported in any way.
    Also it seems like RichTextBlock doesn't support changing color at runtime. Any ideas on how to solve this?
    Sure it is easier to use those files in the project, but I made the plugin mostly so Blueprint-only users can have the RichTextBlock

    About the Images, I'm pretty sure that there's a way of implementing images between text. Have a look on the Slate Test Suite (available at the developer tools), there they did it. Unfortunatelly I don't have time - again :/ - to mess with it, but have a look at STestSuite.cpp (Engine/Source/Runtime/AppFramework/Private/Widgets/Testing/STestSuite.cpp), thats where they implemented all the tests.

    About the line breaks, in UMG try to hit Shift+Enter, that should add a new line. If you want to do that from blueprints, you probably need to append the string/text with a Shift+Enter in a text input field Kind of hacky, but it works!

  36. #36
    0
    @iUltimateLP! do you have any new version about this UMG Rich Text Box?I make a c++ code type based this plagin,but when i try to add a hyperlink func,i jamed...i saw the multi-colored function is implemented by SRichTextBlock,just call "SetText"func and get a FString with stardand color code like "<span color="#ffffffff">Text</>",but i can't find how/where to analysis"span color=",and don't know how to add a hyperlink decorative words....
    I find STestSuite file,but is a little difficulty to my c++ skill... PS:i'm using 4.14
    Last edited by lxydlh; 02-17-2017 at 04:30 AM.

  37. #37
    0
    The plugin is not compatible with 4.15.
    Can you please update it?

  38. #38
    0
    This plugin works great in PIE and Standalone but stops working when running the packaged application, any ideas? (4.15)

  39. #39
    0
    Hi. Plugin it's very usefull.
    But I want to change the format you specify.( "span" )
    Plz Let me know how to change it...(...!!!

  40. #40
    0
    Quote Originally Posted by lxydlh View Post
    @iUltimateLP! do you have any new version about this UMG Rich Text Box?I make a c++ code type based this plagin,but when i try to add a hyperlink func,i jamed...i saw the multi-colored function is implemented by SRichTextBlock,just call "SetText"func and get a FString with stardand color code like "<span color="#ffffffff">Text</>",but i can't find how/where to analysis"span color=",and don't know how to add a hyperlink decorative words....
    I find STestSuite file,but is a little difficulty to my c++ skill... PS:i'm using 4.14
    It's works!
    FText::FromString(TEXT("<span color=\"#ff0000ff\">This</>"));

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •