Using Widget Style Assets with UMG
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.
answered Oct 15 '14 at 12:46 PM
Nick Darnell ♦♦ STAFF
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 Ben.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.
answered Oct 06 '15 at 08:04 PM
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.
answered Jan 11 '17 at 03:28 AM
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.
(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)
answered Jul 23 '16 at 05:40 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here