x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.15
Tags:
more ▼

asked Aug 22 '17 at 10:44 AM in C++ Programming

avatar image

samuel.schimmel
23 1 3 5

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Aug 22 '17 at 02:00 PM

avatar image

Nachtmahr
6.8k 142 24 165

avatar image jigglesworth Apr 29 '18 at 05:13 PM

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.

avatar image Herv99 Jun 09 '18 at 01:07 AM

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.

avatar image Shadowriver Jun 09 '18 at 03:37 AM

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

avatar image jigglesworth Jun 09 '18 at 02:47 PM

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.

avatar image Shadowriver Jun 09 '18 at 04:05 PM

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.

avatar image Kiruse Jun 10 '18 at 10:16 AM

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.

avatar image Nachtmahr Jun 10 '18 at 11:35 AM

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

(comments are locked)
10|2000 characters needed characters left

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.

more ▼

answered Jan 10 '19 at 08:26 PM

avatar image

Evigmae
1.4k 6 3 7

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question