GameInstance and UMG widgets as Blueprints?

I am thinking whether both GameInstance and any widget I would like to have should be blueprints rather than c++. Issues I could think of when not doing this that way are

  1. Designing the actual Widget.
  2. Loading and creating a Widget instance on GameInstance, i.e. default menu. (in c)
  3. Adding callbacks to specific UI events, i.e. when a button under Widget is pressed.

How would this be done on c++? Also, I can not figure out how to initialize a Blueprinted Widget, containing default menu’s design, I do not seem to be using the corresponding type.

API reference is your dearest friend. Most things you see in blueprints exists in C++, blueprint nodes are very simple C++ bindings, so you do this the same way you do in blueprints, i think you already fimilar with those functions in blueprint:

Only diffrence is in statixc functions in most cases you need to give UWorld* which you can do simply by using GetWorld() from any actor

All UMG widgets are inherent from UWidget so look up that class in API refrence:

The UUserWidget is class of widget blueprint so it’s also importent

Events are normal delegates, you can see them in varables in in button varables:

Best way to get access to UI componet of blueprint widget is to create a base class from UUserWidget and make widget bluepritn based on that class, from that you can grab child widgets using APIs inside that class

Now if you want to design widgets in C++ then i don’t recommendd you to use UMG. UMG is just a blueprint wraper of Slate a UI framework that originally was made for editor but it is also usable in game it self. Native Slate, the way it is design it is incompatible with Blueprint system there for it need UMG to exist there as UMG is made for primarly blueprint use. Slate is a lot more efficient to use in C++ then Blueprintified UMG and you quickly understand why when you see it, here is main docs:

Here good tutorial for beginners:

Slate also provides a lot more features then UMG which only selected stuff is binded, you also have access to all widgets, check out the tree in this page:

But if you plan to involve UMG, then use UMG APIs… or make own C++ UMG Widget to use Slate there, since UMG widget classes are kind of Slate capsules, look up UButton for example (aspecially RebuildWidget function where widget is made):

https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/UMG/Private/Components/Button.cpp
https://github.com/EpicGames/UnrealEngine/blob/ab237f46dc0eee40263acbacbe938312eb0dffbb/Engine/Source/Runtime/UMG/Public/Components/Button.h