CDO Constrcutor failed to find WidgetBlueprint

Hi,

in my GameMode.cpp I load a WidgetBlueprint as follows:

static ConstructorHelpers::FObjectFinder<UBlueprint> Blueprint2(TEXT("WidgetBlueprint'/Game/StarterContent/custom/widget/HUDWidget.HUDWidget'"));

	widgetClass = (UClass*)Blueprint2.Object->GeneratedClass;

widgetClass is a TSubclassOf member of my GameMode and will be used later to display my HUD.

Starting the game in the editor works fine, but when i package the game (in my case win64) and try to execute it, it crashes without an error message.
So i checked the .log file, which includes the following:

[2016.03.23-10.31.34:275][  0]Error: CDO Constructor (ICGameMode): Failed to find WidgetBlueprint'/Game/StarterContent/custom/widget/HUDWidget.HUDWidget'
[2016.03.23-10.31.34:431][  0]LogWindows:Error: === Critical error: ===
Fatal error!

I’ve already done some research and found suggestions like loading the UClass directly (here) instead of the Blueprint which looks something like this:

static ConstructorHelpers::FObjectFinder<UClass> Blueprint2(TEXT("Class'/Game/StarterContent/custom/widget/HUDWidget.HUDWidget'"));
widgetClass = (UClass*)Blueprint2.Object;

Another suggestion was to manipulate a DefaultEditor config file with the following:

bDontLoadBlueprintOutsideEditor=false

Because none of them are working for me I wanted to ask if anybody knows another solution for this problem.

Thank you in advance!

Hello tomgn,

I have a few questions for you that will help narrow down what issue it is that you are experiencing.

Quick questions:

  1. Can you reproduce this issue in a clean project?
  2. If so, could you provide a detailed list of steps to reproduce this issue on our end?
  3. Could you provide the code to any C++ classes that may be involved with this issue?

Hi,

yes I can reproduce it.
my Steps are:

  • Start the Editor through the Epic Games Launcher and select a blank C++ Project without Starter Content.

  • Rightclick in the Content Browser and create a Widget Blueprint, name it ‘widget1’. Then open it and place a button right at the center of the screen. Save and close it.

  • Create two new C++ Classes in the Editor. One with the parent class “Player Controller” called MyPlayerController - the other one with the parent class “Pawn” called MyPawn

  • Open the Project Settings and set the TestProjectGameMode as default - save project.

  • Adjust the dependencies, so that UMG can be used:

TestProject.Build.cs:

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG" });
PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
  • Extend the TestProjectGameMode C++ Class so that it contains the following:

→ post is to long, please see the next comment!

I think that’s all and I don’t forgot a step. If I start the Game in the Editor, it will run without problems and it will even display the button. This tells me that the WidgetBLueprint was loaded successfully.
I can package the game also without errors, but when I’m trying to start the game as a win64 .exe, it crashes and the log file contains the same error message as mentioned above in my question.

TestProjectGameMode.h

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

#pragma once
#include "Blueprint/UserWidget.h"
#include "GameFramework/GameMode.h"
#include "TestProjectGameMode.generated.h"

/**
*
*/
UCLASS()
class TESTPROJECT_API ATestProjectGameMode : public AGameMode
{
	GENERATED_BODY()

		ATestProjectGameMode();

	UPROPERTY(EditAnywhere, Category = "creator")
		TSubclassOf<UUserWidget> widgetClass;

	UPROPERTY(EditAnywhere, Category = "widget")
		UUserWidget* CurrentWidget;

	void ChangeMenuWidget(TSubclassOf<UUserWidget> NewWidgetClass);

	virtual void BeginPlay() override;
};

TestProjectGameMode.cpp:

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

#include "TestProject.h"

#include "MyPawn.h"
#include "MyPlayerController.h"

#include "TestProjectGameMode.h"

ATestProjectGameMode::ATestProjectGameMode() {
	UWorld* const World = GetWorld();

	DefaultPawnClass = AMyPawn::StaticClass();
	PlayerControllerClass = AMyPlayerController::StaticClass();

	static ConstructorHelpers::FObjectFinder<UBlueprint> Blueprint(TEXT("WidgetBlueprint'/Game/widget1.widget1'"));
	widgetClass = (UClass*)Blueprint.Object->GeneratedClass;
	
}

void ATestProjectGameMode::BeginPlay()
{
	Super::BeginPlay();
	ChangeMenuWidget(widgetClass);

}


void ATestProjectGameMode::ChangeMenuWidget(TSubclassOf<UUserWidget> NewWidgetClass)
{
	if (CurrentWidget != nullptr)
	{
		CurrentWidget->RemoveFromViewport();
		CurrentWidget = nullptr;
	}
	if (NewWidgetClass != nullptr)
	{
		CurrentWidget = CreateWidget<UUserWidget>(GetWorld(), NewWidgetClass);
		if (CurrentWidget != nullptr)
		{
			CurrentWidget->AddToViewport();
		}
	}
}

Hello tomgn,

I was able to reproduce this issue on our end. I have written up a report (UE-28930) and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for you time and information.

Make it a great day

You can’t load blueprints at runtime, just their classes. Blueprints are an editor only time feature, they are not included in the packaged game.