[QUESTION] [C++] Migrate C++ code?

Is it possible to migrate C++ code from one project to another without generating each class and copy/pasting the code individually, this would save a lot of time.

Yes, you can copy the files over in Windows Explorer. Then right click and add existing in Visual Studio.

I haven’t been able to get folders to transfer in nicely though, and for the moment can only have filters to organize the files.

Would this work for actors too?

I’ve done it for the whole project. I did it last night, made a new blank C++ project from the compiled Editor, then copy pasted all my source files, .h and .cpp and folders into the new directory, and my content, and config.

Still have to deal with any api changes, and I had to add filters in place of my code folders but I did not have to go back and forth making new code from the Editor. I did try that once and stopped as it was proving too tedious.

One thing to note. Name your new project the identical name to the old one, otherwise you can add a name redirect to your config folder, but the project name is needed for Blueprints.

what do you mean by add existing in visual studio cause i copy pasted the files and it gave compile errors saying this class couldn’t find that class included in it

Past the files into your your project folder under the source folder. Then add in Visual Studio right click on the source folder, then the one under it and select Add->Existing Item. Select your source files that you pasted into the folder.

Save and close Visual Studio. Right click on your project file and select generate visual studio files. Reopen Visual Studio and it should work for you as long as the include names are correct. Generating the project files will create the yournam.generated.h files that you need.

Hello , thanks for the info!
Can you explain a little bit more:

… otherwise you can add a name redirect to your config folder

Thank you, best regards

Basically… your c++ files are linked to a given project name; surely you have notived some #include “MyProjectName.h” in some of your headers ?

As for some reason that eludes me, UE4 does not automatically migrate the c++ files, you have to copy them manually… And of course these includes won’t change by themselves ! Hence, either keeping the same project name or changing your c++ files

Could creating new header “MyProjectName.h” which will #include “TheRealProjectName.h” inside help to make it in a fast and elegant way ?