But it gives me an error:
MainMenuWidget.cpp.obj : error LNK2019: unresolved external symbol “__declspec(dllimport) public: struct FButtonStyle & __cdecl FButtonStyle::SetNormal(struct FSlateBrush const &)” (_imp?SetNormal@FButtonStyle@@QEAAAEAU1@AEBUFSlateBrush@@@Z) referenced in function “protected: virtual void __cdecl UMainMenuWidget::NativePreConstruct(void)” (?NativePreConstruct@UMainMenuWidget@@MEAAXXZ)
From the look of things, I had a similar problem when I was converting my Blueprint prototyping to C++ code, namely button style.
FButtonStyle structure “lives” inside the Slate module, so you need to include that module in the build file.
Navigate to “ProjectName.Build.cs” in Visual Studio, and you’ll find a line of code that looks like this: