Adding Userwidget classes causes compile errors

I have been migrating my old 4.7.6 project to 4.8.1 today and part of that is a simple minimap I made using a custom class based on UMG. However, when I add a class extended from the UserWidget class, I suddenly get compile errors from SlateWrapperTypes.h and a bunch of other UI related classes. Classes at the moment don’t have content apart from the default Unreal generated content. I wanted to start out with empty classes before I start adding content, to make sure any errors I get are not a direct result of my code (good thing I did).

I have made sure to add “UMG”, “Slate”, “SlateCore” to the build file (in the addrange bit), so I am not sure what exactly is going wrong here.

The error in question (I only post the first 5 out of a whole washlist of errors. I reckon they share the same core issue);

Error 2 error C2079: ‘FEventReply::NativeReply’ uses undefined class ‘FReply’ E:\Game Development\Unreal4\Source\UnrealEngine 4.8.1\Engine\Source\Runtime\UMG\Public\Components\SlateWrapperTypes.h 58 1 ActionGamePrototype

Error 3 error C2027: use of undefined type ‘FReply’ E:\Game Development\Unreal4\Source\UnrealEngine 4.8.1\Engine\Source\Runtime\UMG\Public\Components\SlateWrapperTypes.h 53 1 ActionGamePrototype

Error 4 error C3861: ‘Handled’: identifier not found E:\Game Development\Unreal4\Source\UnrealEngine 4.8.1\Engine\Source\Runtime\UMG\Public\Components\SlateWrapperTypes.h 53 1 ActionGamePrototype

Error 5 error C3861: ‘Unhandled’: identifier not found E:\Game Development\Unreal4\Source\UnrealEngine 4.8.1\Engine\Source\Runtime\UMG\Public\Components\SlateWrapperTypes.h 53 1 ActionGamePrototype

Error 6 error C2146: syntax error : missing ‘;’ before identifier ‘FGetCheckBoxState_DelegateWrapper’ E:\Game Development\Unreal4\Source\UnrealEngine 4.8.1\Engine\Intermediate\Build\Win64\UE4Editor\Inc\UMG\Widget.generated.h 33 1 ActionGamePrototype

Okay nevermind, I made a stupid mistake. In transferring to the new version, I completely forgot that if you want to extend from the userwidget class, on top of adding to the build class, you also need to add

#include “Runtime/UMG/Public/UMG.h”
#include “Runtime/UMG/Public/UMGStyle.h”
#include “Runtime/UMG/Public/Slate/SObjectWidget.h”
#include “Runtime/UMG/Public/IUMGModule.h”
#include “Runtime/UMG/Public/Blueprint/UserWidget.h”

to your project header file.

Well I did the includes but it still does not compile.
I have 250+ errors about UserWidget.h

I’m doing it in Third Person Example C++ 4.8.1

Did someone find a fix? Please help!

Did you add “UMG”, “Slate”, “SlateCore” to the “PublicDependencyModuleNames.AddRange” thingy in your .Build.cs file?

Thanks a lot for getting back to me! I’m being stupid and included
include “Runtime/UMG/Public/UMG.h”
include “Runtime/UMG/Public/UMGStyle.h”
include “Runtime/UMG/Public/Slate/SObjectWidget.h”
include “Runtime/UMG/Public/IUMGModule.h”
include “Runtime/UMG/Public/Blueprint/UserWidget.h”
in the wrong place. now everything works fine.

Where in your project header did you add this? I’m having the same problem

Just kidding, it was literally just “MyProjectName”.h, I feel silly. Maybe my issue was a little different, looked like I was using “EngineMinimal.h” instead of “Engine.h”. Adding those line also worked though.

Can someone please tell me where exactly is it written that you need to include all those headers in addition to UserWidget.h ?
I literally spent hours trying to solve this problem and did not find one piece of documentation that would mention that.

more detail
A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums.

As I tried, only UMG.h is needed and indeed it must be placed in PCH (project header).
I will not add a header in PCH until it is really needed, say, until the next time I meet another compile error.

As I tried, only UMG.h is needed and indeed it must be placed in PCH (project header).
I will not add a header in PCH until it is really needed, say, until the next time I meet another compile error.