Hi,
I’m new to Unreal Engine development in C++. After following all the basic tutorials without too much issues, i’m now trying to follow more tutorials.
I’ve just setup and installed:
- Unreal Engine 5.2.1
- Visual Studio 2022 Preview 17.7 build 3. It’s supposed to better handle unreal macros formatting now.
I created a 3D Third person project with content as a c++ project and I opened it in Visual Studio 2022. So far so good : project is compiling well, and everything seems to work.
Now here comes my basic problem, I now try to create a simple header file with some structs inside. And doing this breaks the whole project.
Here is how i reproduce the problem :
-
Add new item…
By default the item location suggested by VS is inside “Intermediate” folder. I know by googling that this is definitely not ok. So it should be in the Source Folder.
-
So I decided to create the .h file in a new Source “subfolder” (yeah… subfolder : Source/Public/Data ) :
-
Now my file is visible in the editor, even though folder structure is not visible.
-
To solve this, I followed some advices and quitted the editor, delete the whole Intermediate, Saved folders and InventoryTutorial.sln from windows explorer and have them generated again using right click “Generate Visual Studio project files” to refresh the whole VS project structure:
-
Files are re-generated well. By launching Visual Studio 2022 again, I can now see my project and proper file structure for my newly created header file :
-
Here is my problem : project doesn’t compile anymore, even tough my header file is quite basic :
Project has 4783 errors, the first ones are :
Severity | Code | Description | Project | File | Line | Suppression State |
---|---|---|---|---|---|---|
Error (active) | E1696 | cannot open source file UBT_COMPILED_PLATFORM/UBT_COMPILED_PLATFORMPlatform.h | InventoryTutorial | D:\epic\Epic Games\UE_5.2\Engine\Source\Runtime\Core\Public\HAL\Platform.h | 126 |
It seems that creating a header file from Visual Studio Editor in a subfolder breaks the whole project.
I found 2 workarounds but not good enough to me :
- Workaround 1 : Create all my files in the same directory (not a good developer’s practice)
- Workaround 2 : Always create my header files through Unreal Editor. (New class… no parent)…
When using workaround #2, then I need to delete the Private folder created (cpp file) as i don’t need it for my struct. Then unreal can compile the whole project. Though Visual Studio Editor loses all the intellisense for this header file.
I’m new to Unreal / C++ development and I’m sure I must have understood something wrong. Can you help me understand why my build/intellisense fails and what is the proper way to work with Visual Studio 2022 and create subfolders and header files easily when developing in Unreal Engine ?