How to set the UI text shadow and color

Hi! I tried finding some documentation about this but I can’t really get it to work, is there a way to set a shadow on the text?

It should be possible but I can’t find any example, other than that I would want to know how to change the color with a new one in another function if that’s possible.

Hi,
I found in the source code some functions for the shadow, these functions are available on the device text_block:

# The direction the shadow is cast. Used only during initialization of the widget and not modified by SetShadowOffset.
DefaultShadowOffset

# The color of the shadow. Used only during initialization of the widget and not modified by SetShadowColor.
DefaultShadowColor

# Sets the direction the shadow is cast.
SetShadowOffset

# Gets the direction the shadow is cast.
GetShadowOffset

# Sets the color of the shadow.
SetShadowColor

# Gets the color of the shadow.
GetShadowColor

# Sets the opacity of the shadow.
SetShadowOpacity

# Gets the opacity of the shadow.
GetShadowOpacity

I tried that but I don’t know what ?vector2 is and most of the functions want it, that’s why I wanted an example :confused:

When you create the widget you can pass in property values, like this:

var _ui: text_block = text_block{DefaultTextColor:= color{R:=1.0, G:=1.0, B:=1.0}, DefaultShadowColor:= color{R:=0.0, G:=0.0, B:=0.0}}

2 Likes

Thank you but the problem is still there, I don’t see the shadow, it probably needs the offset, right? I would need an example of that if possible

You can add more property values when creating the text_block
var _ui: text_block = text_block{DefaultTextColor:= color{R:=1.0, G:=1.0, B:=1.0}, DefaultShadowColor:= color{R:=0.0, G:=0.0, B:=0.0}, DefaultShadowOffset:= option{vector2{X:=2.0, Y:=2.0}}}

Also seems like you were getting stuck on ?vector2? Anytime you see ? in Verse, that is an option variable, meaning it may or may not have a value. So in the example of a vector2, its either a value of vector2{X:=2.0, Y:=2.0} or false. And you wrap the ?property like this option{value}.

4 Likes

Oh, I didn’t know that “?” meant “option{}”, thank you! But the problem for some reason still persists, I still can’t see the shadow, I’m doing something wrong?

var CountdownWidget : text_block = text_block{DefaultTextColor := NamedColors.White, DefaultShadowColor:= color{R:=0.0, G:=0.0, B:=0.0}, DefaultShadowOffset := option{vector2{X:=5.0, Y:=2.0}}}

I’ll ask again because I would really like to implement this. I tried but still don’t know why I don’t get the text shadow for some reason.

1 Like

I still need to fix this, does someone know how to make a text with the shadow?

From the UEFN Verse docs, this is the correct way to set the shadow. But it might just be a bug that its not working, just like a lot of things in UEFN…

DefaultShadowColor color The color of the shadow. Used only during initialization of the widget and not modified by SetShadowColor.
DefaultShadowOffset ?vector2 The direction the shadow is cast. Used only during initialization of the widget and not modified by SetShadowOffset.

It seems so weird to me, I saw other modes on UEFN where this seems to work, maybe they all used the HUD device, I never touched it so I don’t even know how it works lol

Doing that in my code to show custom messages, seeing just white text whatever I do.


Either canvas is somehow overriding properties, or the text functionality is bugged and not working :confused:

UEFN is a great thing, but I’m really upset by lack of docs and how you need to figure everything out yourself

Try SetShadowOpacity, it may default to 0. I didn’t see anything until I changed this value.

Yes, this actually helped! Didn’t work for text color though, but I understood what the issue was - color RGB values should be in range of [0;1]. After changing that both issues resolved :smiley:

Attaching example of working text setup:

For ones interested - you can see all the available options by Ctrl-Clicking text_block. Then you’ll see all the methods you can use, and by clicking text_base you’ll see even more.

Also you can shorten it by passing everything to the constructor, though I couldn’t find option for shadow opacity, so you should set it separately :frowning:

6 Likes

Thank you for this post!
The problem for me was the shadow offset.
In UMG you can set a low value such as X = 0.2, Y = 0.2 but in Verse to see any results the value needs to be much higher:
option{ vector2{ X:=4.0, Y:= 4.0 } }