Can't create new folder for C++ class

How do I create a new folder for my C++ classes? I right-click where all the other folders are and the option to create a new folder is grayed out.

Similarly, I created a new temporary class (an Actor) and I can delete it in Visual Studio but I can’t delete it in UE. The delete option is grayed out.

Those options haven’t been implement for classes yet.

Someone else asked about deleting classes via the content browser, but it’s tricky as the classes shown in the content browser don’t have a 1-to-1 mapping to a file as they at least correspond to one .h and one .cpp file, and multiple classes can be contained within the same file.

In the future the content browser may show you the full source tree, at which point we would be able safely delete source files as we’d have the required 1-to-1 mapping between files and content browser items.

You can create new folders by specifying a sub-folder when creating a new class in the editor. This will create the source files in the given sub-folder, which will then appear in the content browser as folders are inferred from the source file location on disk.

Is it possible to move already-created classes from the top level folder to a subfolder? I haven’t tried this yet, though I’m imagining I’ll get UBT compile errors about not being able to find the files in the original location if I do…

Keep record of the original class location, for if this fails. Create the file you want to move it to in the content browser. Create a C++ class template that is the same as the C++ class template you used the create the class you want to move, name it something else. Copy the content by sub class. Delete the original class. All done. There is a way you can delete a class but takes a bit of time(My method.).

Sure, just move the files and re-generate projects (right click on your .uproject file to see the option). This will allow UBT to update whatever it needs to with the new location of the files.

You don’t need to worry about class redirects either providing you’re not moving the class into another module.

The only thing you may have to update is any includes you’ve added for your class, but this will only be an issue if your class header is within the Private folder for your project, as all the Public paths are added to the known include paths by default.

This only updates the visual studio project. The content browser still shows the class at the original location.

Did you build your project after moving the class and re-generating projects?

You are talking about moving the folders in the project structure, not inside the editor, am I right?

Yes, specifically moving them on-disk and then re-generating projects.

Ok, I found it to work if you build thew new solution in VS (F7) before re-opening the editor.

Has there been a solution implemented for this?

1 Like

Hello, I just want to share my findings.

First of all, Unreal wants to have a Public/Private file structure with the subfolders inside such in this post. If you select Public or Private and then put the folder name it will make the folder as well add it in the content manager. If you do it once, It will always default to ask you for making the class Public or Private

Now if for some reason don’t want to put the files in a Private/Public Structure
You can omit it but you need to do the following edit in the .cpp file.

If you made the X_Class in the Y_Folder, you will have the header

#include "Y_Folder/X_Class.h"

You need to either Remove the Y_Folder Or add the Z_RootFolder

#include "X_Class.h"
or
#include "Z_RootFolder/Y_Folder/X_Class.h"