Download

USTRUCT is not working

Hi,

I’ m working with Version 4.6 and try to learn this course: [Converting Blueprints to C++ - Unreal Engine](https://Converting Blueprints to C++).
In the course they are creating a new C++ class (Object) and change the content to a USTRUCT.
I tried to copy this and I always get some Errors. In Detail, i make the following:

  1. Create a new C++ class. In contrary to the tutorial, I can not just right click in the content browser (there is no C++ class):

  2. I need to use File or the Folder “C++ classes” - Maybe that is new in 4.26 vs the tutorial… :


  3. I create a class (Object Type) like in the tutorial:

  4. Then I get a hot-reload Error. This is not happening if I make the same step in a blank C++ Project. Don’t know why…:
    image

This is the Error Code:

CompilerResultsLog: Reflection code generated for BlueprintsToCppEditor in 4,1128458 seconds
CompilerResultsLog: Building BlueprintsToCppEditor…
CompilerResultsLog: Using Visual Studio 2019 14.29.30038 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
CompilerResultsLog: Building 6 actions with 12 processes…
CompilerResultsLog: [1/6] QuestInfo.cpp
CompilerResultsLog: E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Source\BlueprintsToCpp\Quests\QuestInfo.cpp(4): fatal error C1083: Datei (Include) kann nicht ge?ffnet werden: “Quests/QuestInfo.h”: No such file or directory
CompilerResultsLog: [2/6] BlueprintsToCpp.init.gen.cpp
CompilerResultsLog: [3/6] QuestInfo.gen.cpp
LogMainFrame: MainFrame: Module compiling took 13.758 seconds
Warning: HotReload failed, recompile failed
Warning: RebindPackages failed because compilation failed.
LogSlate: Window ‘Message’ being destroyed
Message dialog closed, result: Yes, title: Message, text: Successfully added class ‘QuestInfo’, however you must recompile the ‘BlueprintsToCpp’ module before it will appear in the Content Browser. Failed to automatically hot reload the ‘BlueprintsToCpp’ module.
Would you like to open the Output Log to see more details?
LogSlate: Window ‘Add C++ Class’ being destroyed
LogSlate: Took 0.008408 seconds to synchronously load lazily loaded font ‘…/…/…/Engine/Content/Slate/Fonts/DroidSansMono.ttf’ (77K)

  1. Next I Reload All in VS:

  2. The new created Class:
    image

  3. I change it like in the tuorial. This picture is from the tutorial. Later he changes the struct name from “UQuestInfo” to the correct “FQuestInfo” :slight_smile:

  4. Here is my version:
    image

  5. Then I build the solution:
    image

  6. Gives me the following errors:

Build started…
1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: BlueprintsToCpp, Configuration: Development_Editor x64 ------
2>Building BlueprintsToCppEditor…
2>Using Visual Studio 2019 14.29.30038 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
2>Building 4 actions with 12 processes…
2> [1/4] QuestInfo.cpp
2>E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Source\BlueprintsToCpp\Quests\QuestInfo.cpp(4): fatal error C1083: Cannot open include file: ‘Quests/QuestInfo.h’: No such file or directory
2>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.MakeFile.Targets(45,5): error MSB3073: The command ““C:\Program Files\Epic Games\UE_4.26\Engine\Build\BatchFiles\Build.bat” BlueprintsToCppEditor Win64 Development -Project=“E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\BlueprintsToCpp.uproject” -WaitMutex -FromMsBuild” exited with code 6.
2>Done building project “BlueprintsToCpp.vcxproj” – FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========

  1. It seems for me that the system has some problems with the directory Quests/QuestInfo.h in the QuestInfo.cpp. The directory and #include was created by Unreal itself. I did not change anything… But now I tried to change it to:
    image

  2. With this directory change i get no more errors:

Build started…
1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration
2>------ Build started: Project: BlueprintsToCpp, Configuration: Development_Editor x64 ------
2>Building BlueprintsToCppEditor…
2>Using Visual Studio 2019 14.29.30038 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
2>Building 4 actions with 12 processes…
2> [1/4] QuestInfo.cpp
2> [2/4] UE4Editor-BlueprintsToCpp-0008.lib
2> Creating library E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Intermediate\Build\Win64\UE4Editor\Development\BlueprintsToCpp\UE4Editor-BlueprintsToCpp-0008.lib and object E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Intermediate\Build\Win64\UE4Editor\Development\BlueprintsToCpp\UE4Editor-BlueprintsToCpp-0008.exp
2> [3/4] UE4Editor-BlueprintsToCpp-0008.dll
2> Creating library E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Intermediate\Build\Win64\UE4Editor\Development\BlueprintsToCpp\UE4Editor-BlueprintsToCpp-0008.suppressed.lib and object E:\UnrealEngine\02 Starter Kit Overview\BlueprintsToCpp\Intermediate\Build\Win64\UE4Editor\Development\BlueprintsToCpp\UE4Editor-BlueprintsToCpp-0008.suppressed.exp
2> [4/4] BlueprintsToCppEditor.target
2>Total time in Parallel executor: 1,83 seconds
2>Total execution time: 2,56 seconds
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 1 skipped ==========

  1. But the C++ class is not showing anymore in the Content Browser - even if I recompile or build the solution:

I don’t get this error. I also made a new C++ class project and tried to create a struct by a new C++ class Object and I get some similar errors and finally the C++ class is just not showing anymore in UE4 Content Browser… But it is still in the project folder.
I tried to google the problem and have seen many problems with USTRUCT (UE really makes many problems…), but not the same like mine. Even if I got no problem with the Struct Header, then how can i manually link my header file again? Its still here:

Sorry for the long Post, but like pictures to show really what I’m doing and to make it easier to find the problem.

Edit:
I made a new test and changed the USTRUCT back to a UCLASS:

Recompiled and there is the QuestInfo in the content browser:
image

So there has to be a problem with the USTRUCT. Please help me, I really don’t know what it could be.

Greeting, Tommy

Hi, I can’t answer your question, only telling how its for me:

I need to change it every time I create the new class inside a subfolder. So this part is not limited to USTRUCT. They do show up in the content browser for me though (in subfolders). So for example inside the C++ Classes I have some folder AI inside that another folder CoverSystem and in that are the classes.

So you “should” have some folder Quests inside your C++ classes and then QuestInfo inside that folder (like in your last image).

Did you try to restart the engine after compiling the code?

  1. Then I get a hot-reload Error.

I also get that all the time, no idea why. But I try to avoid hot reload as that often causes blueprint corruption and engine crashes for me, in the end I find it faster to close engine compile restart instead of finding/repairing corrupted blueprints =)

No, it does not show up in the subfolder in the content browser. Like you see here:
image
And here:
image

But I tried to access my struct and this seems to work. So it’s just the problem with not showing any class in the content browser…

And yes, i restartet many times. I also deleted and created the class again.

I think USTRUCTS don’t end up in the Content Browser. only UCLASSes.

@NachoMonkey: Ah okay, that is interesting. Is there any logical reason to it? I don’t really get UE4 in this case.

I think it’s just by design… UObjects and structs in UE are very different. Is there a reason you want to see it in the Content Browser?

No real reason - I just thought it’s not there so I can’t work with it. But it seems it doesn’t matter. But what is the advantage of showing the headers with classes but not the headers with structs? I don’t get the logic for this.

“C++ Classes” is probably a reference to “UClasses”… Also, UStructs are for containing data, and less oriented to operations and long-term existence. Only UObjects support GC.

Okay that is acceptable :smiley: . Thanks for your answer!

Yes, if your .cpp only implements a struct, there’s no class there to show up in the class browser.