# How do I add my own widget to this loading screen system?

**URL:** <https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Blueprint, CPP, question\
**Created:** [November 19, 2023, 9:50pm UTC](https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900 "2023-11-19T21:50:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bradjoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bradjoe1](https://forums.unrealengine.com/u/Bradjoe1)\
**Post date:** [November 19, 2023, 9:50pm UTC](https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900/1 "2023-11-19T21:50:10Z")

</div>

Ive been racking my brain trying to make a a proper loading screen system and came across [This tutorial on the wiki](https://unrealcommunity.wiki/loading-screen-243mzpq1)  
However I cannot figure out how to use my onw widget blueprint instead of “NewTestLoadingScreen”

I am very very new to C++ so im not sure where to even begin. I assume I need to create a C++ class to use as the parent for my Widget Blueprint, make a reference to it in the game instance file and then somehow call it.

Here is my code for my Game Instance C++ file

#include “BP\_ShiverPineGI.h”  
#include “MoviePlayer.h”  
#include “Blueprint/UserWidget.h” // Include the UserWidget header  
#include “W\_LoadingScreen\_P.h” // Include the header for your custom loading screen widget

void UBP\_ShiverPineGI::Init()  
{  
Super::Init();

```
FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UBP_ShiverPineGI::BeginLoadingScreen);
FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &UBP_ShiverPineGI::EndLoadingScreen);

```

}

void UBP\_ShiverPineGI::BeginLoadingScreen(const FString& InMapName)  
{  
if (!IsRunningDedicatedServer())  
{  
FLoadingScreenAttributes LoadingScreen;

```
    LoadingScreen.bAutoCompleteWhenLoadingCompletes = false;

    LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();

    GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}

```

}

void UBP\_ShiverPineGI::EndLoadingScreen(UWorld\* InLoadedWorld)  
{

}

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [November 19, 2023, 11:37pm UTC](https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900/2 "2023-11-19T23:37:03Z")

</div>

> [@Bradjoe1](#):
>
> NewTestLoadingScreen

header file

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "Blueprint/UserWidget.h" 
#include "MyGameInstance.generated.h"

/**
 * 
 */
UCLASS()
class LSCREENTEST_API UMyGameInstance : public UGameInstance
{
	GENERATED_BODY()

public:
    virtual void Init() override;

    UFUNCTION()
    virtual void BeginLoadingScreen(const FString& MapName);
    UFUNCTION()
    virtual void EndLoadingScreen(UWorld* InLoadedWorld);

    UPROPERTY(EditAnywhere, BlueprintReadWrite)
    TSubclassOf<UUserWidget> LoadingWidget;

};

```

cpp file

```auto
// Fill out your copyright notice in the Description page of Project Settings.

#include "MyGameInstance.h"
#include "GameFramework/PlayerController.h" 
#include "Kismet/GameplayStatics.h"
#include "MoviePlayer.h"

void UMyGameInstance::Init()
{
    Super::Init();

    FCoreUObjectDelegates::PreLoadMap.AddUObject(this, &UMyGameInstance::BeginLoadingScreen);
    FCoreUObjectDelegates::PostLoadMapWithWorld.AddUObject(this, &UMyGameInstance::EndLoadingScreen);
}

void UMyGameInstance::BeginLoadingScreen(const FString& InMapName)
{
    if (!IsRunningDedicatedServer())
    {
        FLoadingScreenAttributes LoadingScreen;
        LoadingScreen.bAutoCompleteWhenLoadingCompletes = false;
        LoadingScreen.WidgetLoadingScreen = FLoadingScreenAttributes::NewTestLoadingScreenWidget();
        /*
        LoadingScreen.MinimumLoadingScreenDisplayTime(-1.0f);
        LoadingScreen.bAutoCompleteWhenLoadingCompletes(true);
        LoadingScreen.bMoviesAreSkippable(true);
        //LoadingScreen.bWaitForManualStop(false) {}
        */
                
        if (LoadingWidget != nullptr) {
            UUserWidget* LoadingWidgetInstance = CreateWidget<UUserWidget>(this, LoadingWidget);            
            LoadingScreen.WidgetLoadingScreen = LoadingWidgetInstance->TakeWidget();
        }
        
        GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
    }
}

void UMyGameInstance::EndLoadingScreen(UWorld* InLoadedWorld)
{

}

```

Be sure to make a blueprint GameInstance based on UMyGameInstance and inside of it set the LoadingWidget parameter.

Set the BP GameInstance in the project settings.

OFC set your own project api for the file

[LscreenTest.zip](https://forums.unrealengine.com/uploads/short-url/2ALO2kDjAUEXn5w48cqEwqdJLxs.zip) (24.8 MB)

---

<div class="post-metadata">

**Author:** ![Bradjoe1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bradjoe1](https://forums.unrealengine.com/u/Bradjoe1)\
**Post date:** [November 20, 2023, 1:31am UTC](https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900/3 "2023-11-20T01:31:14Z")

</div>

Thanks! that worked!

I have one more question, is it possible to only call the loading screen when I desire (in blueprints) as a function? because as of right now its tied to the delegates and spawns every time a level is opened. Sometimes I don’t want a loading screen.

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [November 20, 2023, 12:20pm UTC](https://forums.unrealengine.com/t/how-do-i-add-my-own-widget-to-this-loading-screen-system/1404900/4 "2023-11-20T12:20:04Z")

</div>

[LscreenTest\_updated.zip](https://forums.unrealengine.com/uploads/short-url/1YONGifol8VhlpN7CU2eh5MAXux.zip) (24.9 MB)

Updated the project to allow manual and auto loading screens.  
Take into account it’s just an enforced widget. You will have to add in logic like disabling the using input and setting the correct z-index of the widget to make sure it covers all other widgets.

Would have uploaded sooner but the manual widget was being garbage collected between loads and would cause a crash on the removefromparent check.
