What is the recommended way to reuse UMG Styles?

Hello,

after some digging around I notices that it seems to be impossible to make a style for certain UMG elements in order to reuse them.

The Slate Widget Style seemed to be the way to go here, but apparently we can only create the assets but there’s no way to actually use them?

My current problem is that I have several Checkboxes that I use over multiple widgets and if I want to change their style I have to go through all of them manually.

My question is now what the intended workflow for this is. I feel like I’m missing something here.

Hello Robin,

The Slate Widget Style asset is still used with Slate but not directly with UMG (there may be some way to expose that via C++ but I would have to check with our team here to see if that’s a viable option).

About your setup, for your checkboxes are you creating checkboxs each time within each of your widgets or are you using a UserWidget (just a Widget Blueprint with your desired checkbox setup) and populating your other widgets with it?

If you create a “checkbox” Widget Blueprint you can populate your other Widget Blueprints with it and make changes to the “checkbox” Widget Blueprint that will be reflected in each of the others. You could also expose parameters that are set upon construction to allow you to tweak settings on a per instance basis.

There’s also Named Slots you can use to customize what is “wrapped” with your checkbox you could use as well.

-W

Hey Robin,

Yes, you are correct. I would create a Checkbox Widget Blueprint and on its Event Construct, Set Style for it with a publicly exposed variable that is also exposed on Spawn (this will allow you to change it inside its parent Widget Blueprint).

Instead of casting, you could off the OnCheckStateChanged event call an Event Dispatcher (called whatever you wish). This Event Dispatcher will be exposed as well inside the Checkbox Widget Blueprint when you place it inside another Widget Blueprint (so it gives you the same functionality you are looking for).

I’ve thrown together a quick example here: - YouTube

-W

Hi Wes,

I basically have a “main widget” with 3 checkmarks and then a sub widget with another one. The sub widget gets added about 16 times to the main widget though. My current workaround is to use “Get Style” the style of one of my checkboxes and apply it with “Set Style” to the others. In the sub widgets I just grab the variable from it’s parent and apply it to my checkbox there. That seems to work fine so far.

About the “checkbox widget” you were talking about.
With that you mean a normal widget where I place a checkbox and then place the new “checkbox widget” inside of my other ones?
I tried that and I miss the “OnCheckStateChanged” functionality. I guess it’d be possible to cast it over, but with that I’m worried about the performance impact of things. Does it have a noticable impact to place widgets inside of widgets instead of building them up inside of them? And how about casting stuff back and forth between them?

Thanks for your replies.

Oh wow that’s certainly interesting.
Thanks for actually taking the time and making a video!

No worries, let us know if we can be of further assistance or if other questions come up! :slight_smile: