How do I move a C++ class to a different folder?

I would like to move a C++ class to a different folder. When I try to drag the class into the Content folder it says “C++ classes cannot be moved or copied.” When I try to move it to a subfolder within C++ Classes, it says that the folder “is not a valid place to drop assets.” What is the best way to move C++ classes to different folders? Should I do it in Windows Explorer? Do I need to just make a new class? If so, do I also need to remake all classes that derive from the class?

1 Like

If you move C++ Classes around you potentionaly mess them up. If you want to move them do it in the Explorer (but keep them in the Source folder!) and right click on your .uproject and hit Regenerate Project files. Fix up the potential mess you created and Compile. Done.

2 Likes

I’m amazed Unreal has such a bad system for C++ organization. I’ve tried many times but I can’t figure out how it’s deciding what to render in the Unreal C++ folder. If someone has a good resource that shows me how to create and manage C++ files in unreal please share because the current setup is not intuitive at all.

2 Likes

Basicly what I do is create the same filename in the folder where I wanted to move it, copy/paste it all, change the references and delete the old file.

1 Like

That folder was made to keep UI integrity with Blueprints which are also classes, it was not made for C++ files management, you either to that in IDE or file manager (Explorer for example). What you looking for is Class Viewer, “Window”->“Developer Tools”->“Class Viewer”, btw you cna see blueprint classes there too

As a developer you need to be able to organize your files intuitively for efficiencies sake. And also, often what happens in larger projects are architectural refactors which I’m still finding a massive hassle in unreal. The class viewer and unreal C++ classes folder just don’t cut it. For such a fantastic engine, the lack of proper file management built in feels like an oversight. The time spent moving files, making sure they recompile, deleting stuff in the intermediate folder to force UI refresh, rebuilding to try and get them to appear in the C++ Classes folder. The list of hassles just keeps going for something that should be dealt with much more elegantly.

I know at this point I’m just complaining. But I think it’s a valid complaint.

2 Likes

Thats because Unreal Enigne was never ment to be coding editor, in fact UnrealScript editor was removed in the past probably because Epic didn’t want to deal with it and allow code workflow freedom with custom IDEs. Ever since editor’s focus group seems to be art and level designers rether then coders

Content browser also not file manager, it shows active asset UObjects relevant to the code and be independed from packaging method, good example is FMOD which has only 2 files for it sound bank but in content browser you see contence of those banks. Again C++ forder is only there for blueprint only people, which see actor classes as assets insted of classes, which if you ask me is design flaw, because it not trully represent nature of code classes. In past Class viewer was main viewer of classes, it probably because Epic wanted to store Blueprints as assets and didn’t want to confuse people with two viewers, thats why class viewer was hidden away.

Hot reload is indeed buggy, primerly due fact that in order for it to work engine need to unload old module and load another without creating holes in the memory which may cause crashes and losing data, because UE4 is so huge and code module can contain practically anything it hard to keep everything work properly in this progress. It is always the better to turn off and on the editor on compilation. It was introduced around 4.3 and constantly improving, if you find replicable bugs raport them.

All of that is true. It would still be highly useful to be able to move a C++ class through the editor in order to preserve inheritance. Moving a class is highly detrimental to Blueprints inheriting from them. More often than not I need to write the Blueprints anew from scratch, because I can’t even open them anymore. Which leads us back around to the OP’s issue.

In case of BP or any other Asset not knowing about your C++ or file Changes go to your Engine Folder and navigate to Engine/Config/BaseEngine.ini

In this file you can see Examples and Documentation for redirections. Be it a Property field / Class / Package or Module doesen´t matter you can reroute pretty much anything you break.

In your Project Config Folder there is also a BaseEngine.ini where you can add those Redirects to avoid to remake any Blueprint like Kiruse mentioned.

Please remeber that your VS does not have any knowledge about anything created inside the Editor. And anything you created Inside the Editor is not aware of changes you did in Code or the File System, therefore Redirects exist so you can make the connection when the Engine starts Loading.
Once the Editor is fully loaded it would technicly be possible to make a feature to move C++ around, but the effort the Epic Staff have to put into this Feature is to put it simply “to high” for the return of value. And don´t forget the maintance Cost.

Hope this Clears things up and I don´t get Notifications anymore about that Post x)

Cheers

What I do is a make a copy of the file i need moved, update every dependency, make sure everything works as before with the new file, then delete the old one.

Usually takes like 1-2 min of my time and i don’t need to fight with anything in the process.

Here is explained how to do transfer between folders and how to remove C++ classes

Using Rider, you can simply drag and drop the C++ files inside the editor. After that, you just have to update the references to the moved files (build the project and you’ll get a list of errors to fix)

Rider for anyone else - https://www.jetbrains.com/lp/rider-unreal/