Hello all! New to UE4, had a question about something peculiar occurring in my blueprints.
When leaving an input empty (a SlateColor) it is automatically defined as FF00FFFF - I’m wondering how to change this automatic definition, or how to ‘allow’ empty inputs to take on a default value that is defined elsewhere.
Quick description -
- Contains UI for the player, including scores and timers, however most importantly, contains a message log (scroll box) in the lower left corner of the screen.
- A stand alone custom widget(Literally just a Text Block - with some variables and setter methods - also the default color value i’d like the text to take on if no inputs are defined)
Every time Print String (to UI) is called, it fires off a custom event called PRINT_STR. In that event, a Print_Msg_Block is created, and then customized via a function called Customize Print Message (which is defined in Print_Msg_Block blueprints).
I didn’t want 2 separate functions, for PRINT_STR and PRINT_STR_WITH_COLOR, so I set a default color in Print_Msg_Block (and this color is bound to the color of the Text Block widget). My thinking was that I could simply leave the color input empty, and the default is chosen. But due to the structure, as you will see, leaving the input empty creates a ‘default’ hot pink color with a hex value of FF00FFFF.
So, here’s the default value defined in Print_Msg_Block for my MessageColor variable (which is bound to the color of the actual Text Block):
Now here’s what I want - The winning message to be green, and the regular message to be that blue color defined in MessageColor:
Since the False-branched “Print String(to UI)” is empty, I’d like it to take on the blue color. But it doesn’t. This is what happens:
And here’s why:
It seems the default SlateColor is FF00FFFF. Without passing one, one is automatically created with that damned default value. And the way my blueprints are structured, it sets the input received (which is this newly created FF00FFFF color) to the MessageColor variable which is bound to the actual color). Here’s the structure of the print sequence:
Print String (to UI) calls a Custom Event defined in Game_UI’s blueprint:
Which does the usual Widget-y stuff, but also calls Customize Print Message defined in the Print_Msg_Block blueprint (also, someone please tell me if there’s a cleaner way to keep the Scroll Box scrolled to the bottom, as every new entry sets the scroll bar to the top):
And finally, here’s Customize Print Message. It simply has to set the variables since they are both bound to the correct things (Text Field and Color Field) in the TextBlock in Print_Msg_Block:
- How do I get my default blue value (defined in Print_Msg_Block.MessageColor), to be passed when there is no input sent? How do I get a function to realize that there was no specified input? How do I stop it from automatically sending a color when there’s none defined?
- *] I toyed around with using a boolean value as an input, to indicate whether or not a color is specified and act accordingly, but it’s really easy to screw that up, it’s an extra-complication that I don’t like.
- What’s a better way to keep the scroll box scrolled at the bottom-most position? Set Scroll Offset to 9999999 is a dirty hack.
Thank you very much for reading!