// Put this in the .h file. GameInstance, GameMode, HUD, PlayerController should be ok
// You need a reference to a class of your UMG widget
// You may setup the value of this property through blueprint
UPROPERTY(EditDefaultsOnly, BlueprintReadonly)
TSubclassOf<class UUserWidget> MyWidgetClass;
// Then you need a place to store your created widget to show/hide it and garbage collector won't destroy it
UPROPERTY()
class UUserWidget* MyWidget;
// Put this in .cpp. In BeginPlay for example
// Create the widget
MyWidget = CreateWidget<UUserWidget>(GetWorld(), LoadingWidgetClass);
// Display widget on screen
MyWidget->AddToViewport();