Bug: Add C++ Class popup doesn't prefill new class Path with Public/ until clicking on Private then back to Public

Issue

When you create a new class (Add C++ Class), on the “Name your new object” window, the Path is initialized as “path/to/project/”. The Public tab starts highlighted.

image

If the user wants to add the class in some Character/ sub-folder, and don’t pay attention to this, they may just enter the subfolder name, resulting in “path/to/project/Character” without “Public” nor “Private” intermediate folder. The Public tab loses highlight in that case.

image

When doing this, the header .h will be placed outside Public/Private folder, and the source .cpp besides it too.

This generally result in build errors later on include, such as:

Cannot open include file: “Character/MyCharacter.h” : No such file or directory

(see Why is it not possible to create folders unless you set a Class to public?)

At first I thought it was intended to allow the user to place wild headers like enums, but this is pointless if one cannot include them at all.

In addition, unlike previous versions of Unreal, where neither Public nor Private would be selected at first, Public is now selected (highlighted) by default. Besides, when clicking on Private, the “Private/” sub-folder is appended…

image

… and when clicking back on Public, the “Public/” sub-folder is correctly appended to “path/to/project” this time.

image

so it seems that auto-adding Public was intended, and should be also added on Path initialization for consistency.

In fact, if you click on Public after adding sub-folders, you also get the Public/ folder inserted between path/to/project and subfolder (and same for Private).

image

which is currently the most efficient way to do it (no need to manually private Public nor Private).

Suggested fix

The first time user arrives on the class creation “Name your new object” window, auto-fill Path until “Public/” as if user clicked on Private then back on Public. User can then keep working directly in Public folder, or switch to Private, and/or add sub-folders.

If they really want to put files outside Public/Private folders e.g. to work on draft scripts, or maybe some external module, they can do so, in which case when removing Public/Private intermediate folder entirely, the Public/Private tab could be unselected/lost highlight. But that would be the rarer case.