ue4plugins / LoadingScreen

A plugin for Unreal Engine 4 to expose simple controls for managing load screens.
MIT License
508 stars 162 forks source link

[POSSIBILITY CHECK] UMG Utilization #32

Open azelenski opened 6 years ago

azelenski commented 6 years ago

Hey,

I want to know, isn't it possible to show a UUserWidget on this Loading Screen?

I'm trying to implement that by providing a reference to my UMG Blueprint and utilize it during loading process. But my problem is that I'm weak in C++ and a specially C++ Unreal stuff and this is hard for me to estimate is this I who is writing code with wrong syntax or this is just impossible due to other limitations.

I'm pushing a new property declaration into LoadingScreenSettings.h like so:

// Reference UMG Asset in the Editor UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") TSubclassOf wMainMenu;

// Variable to hold the widget After Creating it.
UUserWidget* MyMainMenu;

this is fine, i can provide a UMG BP class to it from editor. and after I need to do something like this in LoadingScreenModule.cpp:

if (wMainMenu) // Check if the Asset is assigned in the blueprint. { // Create the widget and store it. MyMainMenu = CreateWidget(this, wMainMenu);

    if (MyMainMenu)
    {
        MyMainMenu->AddToViewport();
    }
}

and here comes my troubles. [1] MyMainMenu = CreateWidget(this, wMainMenu); // I need to provide a ref to current PlayerController instead of 'this' but i don't know how to get it (if possible at all) [2] Trying to get this player controller by doing this: GEngine::GetWorld()->GetFirstPlayerController(); [3] Trying to access wMainMenu and MyMainMenu like followings: Settings->StartupScreen.wMainMenu and Settings->MyMainMenu [4] Is this totally possible to add the UMG into this?

lucastucious commented 6 years ago

Same question !

nickdarnell commented 6 years ago

No - it can't be created early enough for startup screens - and you'd be running blueprints on another thread. We don't do it in any of our games - the only place it's safe to do is when you're doing server travel / streaming and you don't hard block on loading the levels - in which case it's all running on the main thread still.