What is the difference/relationship between UWidget (eg - UButton) and SWidget (eg - SButton) and how are they supposed to be used?

Hello, The topic Says it all -

What is the difference/relationship between UWidget (eg - UButton) and SWidget (eg - SButton) and how are they supposed to be used?

Much Appreciated.

. . . . .

Hey there,

SWidget uses the Slate Module and it’s used for slate related stuff:

class SLATECORE_API SWidget	: public FSlateControlledConstruction, public TSharedFromThis<SWidget>

UWidget uses UMG Module and it’s used for UMG related stuff and it’s an UObject

class UMG_API UWidget : public UVisual // UVisual derives from UObject

Since UMG uses Slate on the background i would say UWidget manages the objects (by using UObject garbage collection and functionality). Overall you use SWidget when you want to work with Slate directly and use UWidget when you want to work with UMG.

As far as I understood from this and seeing the code as well as other sources, though I didn’t dive too deep and this is just surface knowledge, is as under -

  1. SWidget or other classes that use Slate module ( hereby referred as Slate Classes) are actual classes that actually create the UI elements such as a button.

2.UWidget or other classes that use UMG module ( hereby referred as UMG Classes ) are for easy handling of Slate classes and in the background, they call Slate classes for any kind of behavior.

3.UMG Classes don’t actually do anything itself, it just calls Slate Classes and only makes changes to Slate Classes properties or call function in Slate Classes,

4.UI can solely be made using Slate Classes without using UMG Classes (Not too sure about this ) though it will be incredibly difficult when compared to using UMG.

I believe so.