Including WidgetBlueprint.h causes compilation errors

Hi guys,

in one of my objects I have this code in constructor:

	static ConstructorHelpers::FObjectFinder<UWidgetBlueprint> widget_blprnt(TEXT("WidgetBlueprint'/Game/MyGame/HumanFighter/W_Unit.W_Unit'"));
	if (widget_blprnt.Object)
	{
		m_UnitWidget = CreateWidget<UUserWidget>(wc.OwningGameInstance, (UClass*)widget_blprnt.Object->GeneratedClass);
	}

this is not compiling. What causes problem is this line :

static ConstructorHelpers::FObjectFinder<UWidgetBlueprint> widget_blprnt(..)

Compiler doesn’t know type UWidgetBlueprint so I included include ā€œEditor/UMGEditor/Public/WidgetBlueprint.hā€. But now I get another error:

Cannot open include file:
ā€˜IMovieScenePlayer.h’: No such file or
directory

What is causign it ? Thanks in advance :slight_smile:

1 Like

You should include in CPP file. Also remeber to add ā€œMovieSceneCoreā€ module in to PrivateDependencyModuleNames in build script of your module (C# file)

1 Like

Hello,

Of course I put include in cpp file, where code of my constructor is. When I added ā€œMovieSceneCoreā€ to module dependencies it causes yet another compilation error:

C:\Program Files\Epic Games\4.8\Engine\Source\Editor/UMGEditor/Public/WidgetBlueprint.h(10): fatal error C1083: Cannot open include file: 'WidgetBlueprint.generated.h': No such file or directory

I’am not shure if this module exsits because it is not present in modules list (accessed via Window->DeveloperTools->Modules from Editor). I’ve tried to add ā€œMovieSceneToolsā€ module instead of ā€œMovieSceneCoreā€ but again it causes strange compilation errors.

By the way: What is the difference brwn private and public modules ?

if you dont have WidgetBlueprint.generated.h then rebuild, the module name i taken from other module that use that header file

OK,

before I asked this question I didn’t know aboud modules and how to add them. To resolve my compiler errors I needed to add two module dependecies. First is UMGEditor so compiler will know UWidgetBlueprint type, second ā€œMovieSceneCoreā€ so linker could locate IMovieScenePlayer.h file.

thanks for help :wink:

3 Likes

I added the dependancy, but still get this error.
Does anyone know how to fix that?
And the file does exist.

Adding ā€œUMGEditorā€ to the PrivateDependencyModuleNames field in the Build.cs worked for me

5 Likes

Worked for me! tnx :slight_smile: