TransWikia.com

UE4 C++ - Add generated source code folders to Visual Studio solution?

Game Development Asked by JSON Brody on February 12, 2021

In Unreal Engine 4, using a Visual Studio solution and projects generated from the Editor using the First Person Template, the layout of the Solution looks something like the following:

Solution Explorer Screenshot

I am not a fan of this flat horizontal folder structure. What I would like to do is put some new classes into a nested folder here.

I will be generating a new GameState subclass, and putting the sources into the SourceGameState folder that will also be created on the fly, using the UE4 editor:

UE4 Editor create new  c++ class

Notice that the "Create New Folder" option is disabled.

Added GameState folder

Here I have appended the "GameState" folder to the normal source path.

However, the folder structure in the Solution Folder has not changed, and nothing I try to do is working. The things I have tried to do so far include:

  • Drag the folder into the solution from the file explorer
  • Right Click > Add > Existing Item… (Which just results in the files appearing horizontally to the other files without the new folder I have created, also add as link is not an available option)
  • Create a "Filter" (what the other folders appear to be) within Visual Studio. This results in the layout I desire, but I have to add the source code files to the filter manually which just copies them to the .vcxproj file directory. I end up not modifying the actual files I added.

How can I add this folder and it’s files while keeping up with the original copies?

One Answer

Answering this myself because I fought this problem for a couple of hours.

After the project has been first generated from within the Editor at:

File > Generate Visual Studio Project Files

The option changes to

File > Refresh Visual Studio Project

I found that the easiest, most effective, and I assume intended way to have the Solution Explorer layout match the actual file/folder structure is to use this to refresh the project. This will require a reboot of Visual Studio, which will also require a reboot of the editor if it's being debugged.

Refresh VS project

Answered by JSON Brody on February 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP