How do I make a Slate Widget Style?

Just stumbled upon this old thread while looking into a related topic and thought i might help anyone that finds this^^

  1. Create your Style class, it needs to inherit from FSlateWidgetStyle. Implement all the UPROPERTYs it needs. Best practice is to also use a decorator pattern for initializing the values later.
  2. You need to register a FSlateStyleSheet at module startup (and unregister it at shutdown) with the FSlateStyleRegistry. In the engine code this is done by having a singleton style class (such as FCoreStyle) create all your FSlateWidgetStyles and register them with the FSlateStyleSheet.
  3. You can now access the singleton style instance via the “Get()” function of your style, then look up the style sheet you need by its key.
  4. If you want to set the style at runtime, you need to create a UObject wrapper that can be used by the SetStyle function in UMG.

I recommend looking at CoreStyle.h/cpp and related source code for the details^^

4 Likes