What are the perks of using [Add Code to Project...]

Up until now I have blindly been adding code to my project with the above menu option, but it occured to me, once i started adding filters to my code in visual studio, that it was clobbering them, even if they had been saved prior or if they were in folders. My question above is, what are the reasons or perks for using this menu option, and when should we be using it. Is it planned to make it so that this menu option doesn’t kill my filters?

Loving the toolkit the deeper into the rabbit hole I get.

Ah, and if we use this as a place to start off, if we delete the three files that are generated should we be able to continue to work as long as we remove the other references to the class?

Another way to ask the question - What do I have to do if I choose to skip over this option and generate classes in the project myself?

This menu option autogenerates a lot of the Unreal template code that you see in the headers and source files. If you just add a new file in Visual Studio it will initially be blank and you will have to copy in (at a minimum) the following:

// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.

#pragma once

#include "MyClass.generated.h"

class AMyClass : public AActor // or whatever else you decide to extend from

for the header and:

// Copyright 1998-2013 Epic Games, Inc. All Rights Reserved.

#include "MyProject.h"

AMyClass::AMyClass(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)


for the class file. Note that all this code (especially the copyright line, found that out the hard way) is required or else your code won’t compile. Also, the tool creates all the files like MyClass.generated.h in your Intermediate folder behind the scenes. Using Visual Studio only, you will have to manually regenerate your files (see below).

But yes, the feature is a bit WIP at the moment. For a custom folder/filter, I find it easier to generate them in the main directory first, then migrate them and regenerate all Visual Studio files (right-click your .uproject file and hit “Generate Visual Studio Files”). That usually works without problems.

The copyright notices are not by any means required for the compilation to complete.

Are you saying that, as long as I create two files of this format the generated file will be created at compilation time?

Really? For me, unless the line is present an error is thrown.

I’m not sure on the second one, having never tried it. To be safe I always manually generate, assuming that because the *.generated.h header does not exist yet compilation will fail.

I am certain, when you said that i went through and removed all of my header comments and it compiled fine.

Visual Studio filters are generated to exactly match the directory structure on disk and there is currently no way to avoid regenerating project files while using the “Add Code to Project” feature. Generally, you are encouraged to allow project file generation to organize your filters for you but it is not required.

As William mentioned, this feature is not required to add classes to your project. As long as you create a .h and a .cpp file in the same location that the wizard creates them, the generated code (*.generated.h) will be created at compile time, without the need to regenerate vcxproj files at all.

Beautiful! I have confirmed that the generated code is created when i drop my own classes in the locations as i wish. No more using the AddCodeToProject option =) Thanks!