Download

Adding files to the solution without using UE4 editor !??

Hi,

Today I tried adding a file directly to the solution (just a simple header file with enum defitions) and at first I got a compile error about not finding .h file, because the file was added to IntermediateFiles by default, for whatever reason. Ok,.so I moved the file from the intermediate files to the correct location, where the other files are, and now the missing .h file error was gone, but the build failed with an error from Microsoft.Make.Targets. MSB3073, (Other Compilation Error).

Then I tried to build using UE4 which gave me a bit more info on the error - something like “unparsed class ‘Class’ found while validating entries for dependson…”

What do I need to do to get the files added directly via VS solution ?

UPDATE:

This could also be due to the fact that I didn’t add something I need in my enum definition ?

Here’s my enum header :

#pragma once

#include “Runtime/CoreUObject/Public/UObject/Class.h”

UENUM(BlueprintType) //“BlueprintType” is essential to include
enum class EWeaponType : uint8
{

}

I am including Class.h header here to get the UMETA and other tags and coincidentally “Class” is also mentioned in that error above:

“unparsed class ‘Class’ found while validating entries for dependson…”

Hehe, this is something that I’ve been having a lot of fun with since I started playing around with the engine.

There are several things you can do, but I personally think that the easiest way to add new files, especially if the editor is not open, is to simply create a new pair of files (cpp + h) in your favorite file browser (Explorer, totalcommander etc.) in the proper subfolder, and then running the solution generator again (right click the uproject file and select Generate Visual Studio project files).

Sometimes I will add files through the editor, but it usually takes almost as long, or even longer than just doing it like that.
I have managed to add files directly through VS as well, but it’s just not worth the extra effort :smiley:

This is definitely one of the more awkward things in the engine though, hopefully someone will make it easier one day :slight_smile:
One idea I’ve had is to create an UE4 VS2013 plugin that helps out with things like adding files, a large library of code snippets (like UPROPERTY/UCLASS generation shortcuts) and maybe even integrating more debugging tools directly into VS. My renderdoc plugin comes to mind for example. I dunno, might be something to think about at least!

Best regards,
Temaran

Yeah this is always pretty tedious.

I’ve found that if I want to add new files I can also make sure that the path I’m creating the .h and .cpp file at is correct in the create file dialogue. For some reason, simply clicking on the folder/filter puts it into that intermediate folder by default.

This is especially tedious when I have all these different directory structures to organize my files, and I have a public folder for headers and private for .cpp just like UT. I end up recreating the same folder hierarchy in private and public.

Thanks for the input. Yeah, I was actually thrown off with that .genereated header, thinking that it gets ONLY generated by the editor. What I didn’t realize is that all you have to do is simply add this header and make sure it’s called the same way as the file, and then “precompile header tool” will actually do what it needs to do to generate that file, when you start the VS build. So here it is for the other noobs wondering the same:

To add a new file (which contains some blueprint visible objects) to the project without using editor, all you have to do is add the file in the appropriate location , then include “.generated” header, and off you go. For example - in my case, I wanted to have a simple header with enum files. So I can simply add a file called MyEnums.h from VS 2013 (make sure it doesn’t try to place it to Intermediate files location), and then add the following at the top:

#pragma once

#include "MyEnums.generated.h"

UENUM(BlueprintType) //“BlueprintType” is essential to include
enum class EMyEnums : uint8
{

}

And that’s it.

Similar with structs, classes, etc (you will need to follow certain naming conventions).

Yeah, you always need to include the generated header, although if you add new files from the editor, it will do it for you :slight_smile:

/Temaran