Download

Why are slate style sets useful?

Hello there!

I just want to do a quick sanity check. I’ve been playing around with UMG and slate with some free time to just get a better feel of how everything in that part of the engine hangs together. I also wanted to do this from C++ since I thought it would be more informative that way, and that’s generally how I like to work anyways. I’ve also done it in-editor quite a lot before, so that isn’t as interesting to me.

Now to my question. I don’t understand why Epic recommends we use slate style sets. Are there any advantages / optimizations I’m missing here? I’ve grepped around in the code to try to find an answer by myself, but I’ve come up with nothing in particular, so I thought I’d just throw it out here on the forum before I move on :slight_smile:

First off, using style sets from C++ you have to use the awful and error prone asset location pattern of “FSlateGameResources::New()”. I tried playing around with skipping this and just using the USlateWidgetStyleContainerBase derived types in UPROPERTies by themselves. I thought I’d just put them on the base HUD class, create them in the engine and then set the properties accordingly. Unfortunately it doesn’t seem to accept subclasses as I got type matching errors.

I then decided to skip deriving from FSlateWidgetStyle and USlateWidgetStyleContainerBase completely, and just create “raw” style objects deriving from UObject and having a few properties like



	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Style")
		FSlateBrush ButtonBrush;


I then propagate them using slate arguments instead of using the service locator FStyle::Get(). Getting rid of some service location always feels nice, so I see that as a plus anyways.
But is there some downsides to doing what I’m doing now?

I suppose since I’m not using the style system, I cannot use my custom styles for UMG widgets, but as long as there is no overlap, then I suppose there is no problem, right?
It’s a pity that the style system does not let you set the UI resources through UPROPERTies directly, hopefully someone makes that happen eventually :slight_smile:

Oh well!

Best regards, and happy new year!
/Temaran