Using Widget Style Assets with UMG

Hi there,

In Unreal 4.5 we now have the ability to set the style of widgets either as a default in the UMG Editor or as part of the graph with a blueprint function.

We also have the ability to create Slate Widget Style assets. However there doesn’t seem to be a way to use these to set the style of widgets in UMG.

I noticed The UButtonWidgetStyle is a Blueprint Type, but the other styles are not, which means you cannot use them in blueprints. Why is this?

The assets themselves are USlateWidgetStyleAsset which also cannot be referenced via blueprints.

Allowing us to use the asset styles, mean we can share the same style between screens and only need to make changes in one place.

Is this a coming feature?
Is there a way I can do this now?

As a note here is what I mean regarding the Button Widget Style Asset being in blueprints:

Style assets are not really intended to be used with UMG any more. Those styles exist because they were developed before UMG, and are still being used by game teams using raw slate. All styling in UMG is currently done with inlined styling, however that is also temporary.

The long term plan is to make styling reusable, but not the way it was. The plan is to make style classes, that can be extended via blueprints or C++ and contain behaviors, allow bindings…etc. As opposed to what they are now, which are just flat structs with no way to encode behavior or additional data. Even if you could reuse a button’s style right now, it’s still not good enough. if you want all buttons to look a certain way AND scale on hover, you’ve got to duplicate the logic which isn’t good.

I don’t have a timeline for the revamp to styles, but we know it’s a problem and we have a plan to replace them. Won’t be in 4.6, we already have a ton of things lined up for that release.

If you need something to be reused a lot, I recommend making the widget a user control that’s just a button or whatever so that you can reuse the style and behavior information. In 4.6 Named slots will make it way easier to re-use user controls by allowing you to expose slotable areas on user controls so that you don’t have to bake out a button that already has text, or an image. You just make a user control that’s a button with a slot.

Cheers,
Nick

Thanks for that Nick! Lots of good info there.

I’m using 4.9 and the UMG designer for my UIs and it is very annoying to change every button (and other components) manualy.

Due to the given info I didn’t use .Driehuis method. What is the best way to use the same style for all the buttons (at least on one screen)? I’m tired of making changes several times just because I have several buttons.

I’m using 4.9 and the UMG designer for my UIs and it is very annoying to change every button (and other components) manualy.

Due to the given info I didn’t use .Driehuis method. What is the best way to use the same style for all the buttons (at least on one screen)? I’m tired of making changes several times just because I have several buttons.

Same problem here.

You can create a ‘parent’ widget with desired style and then derive from it (so instead of creating a new button, you create new widget from 'User Created" section in UMG, selecting this ‘parent’ button) - but it has some caveats, more info here: Universal UMG widget parent for reuse - default variables preview? - Blueprint - Unreal Engine Forums

Hi, Nick!
Are there any news on the Style Classes?
Thanks!

Hello RVillani,

If you would like to reuse styles you could set up a widget and pull off a reference to it to grab it’s style. From there you could promote the style to a variable that can be called and reused. You could also create a widget and then add this widget to other widgets via the user created section. I hope that this information helps.

Make it a great day

1 Like

Another solution to this would be to not have the text be part of the button, instead use an overlay to put it on top of the button user widget and set the text visibility to “Hit Test Invisible”.

This way changes to the button still affect all of them but the text is separate. Of course the drawback is that the text is not styled from the button so you still have to do that manually.

Example Hierarchy:

99668-hierarchy.png

(I know this is an old question but it still comes up as one of the first results when googling this issue so wanted to help out people that are still having these issues)

So in the end due to the original response I ended up coding my own style solution, making a blueprintable class for each control type and having most of the same data as the old styles in there. I then had to extend each of the UWidget classes for the ones I cared about (UButton, UTextBlock etc) and allow them to have a TSubClass of the correct style class, and then wrote some code to take that and apply it to the underlying Slate Widget.

I also made it that any changes to the actual properties on the UButton (Etc) would override the style for that property only. A bit of extra grunt work, but did what we needed it to do.

If anyone else wanted to try such a thing I am happy to share some pointers, of course you need a code based project for this.

So its 2021, has it been replaced? i mean 7 years later haha.
I know the answer, its no.
How do you guys re-use styles?

1 Like

What I do is: instead adding style to a button, I create a widget interface with only one btn which I customize and add behavior(in the event graph). Then I go the main widget and instead adding the default button I add MyButton, they can be added from the left panel called Palette in the designer. I think is way better because this can be applied to any widget, including text or adding a full complex widget to another full complex widget.