Yeah, the unreal build tool should be able to find and parse all of your source files located within your source folder, even if they’re located within subfolders. I have loads of subfolders and don’t have any issues.
Just verify that the plugin source files you think you have a directory path within the source folder and not something else like an intermediate folder. Sometimes UE4 will want to put source files in there and thats wrong.
Also, it is 100% possible to manually create your own classes without using the editor to insert them. I actually prefer to do this myself. There are a few gotchas you have to pay attention to. I wrote up a quick workflow for doing this correctly. Here is my own documentation on how all this stuff works:
Building a UE4 project: What is happening behind the scenes?!
Within the game editor, you add a class to the project and then you open it up in visual studio.
1.0: File -> Add code to project
1.0.1: Name the file
1.0.2: IMPORTANT: Set the folder to the correct source file location! By default, this goes into an intermediate folder.
1.1: If the file is brand new, it hasn’t been added to version control yet (right click -> Add).
Notice that at the top of the header file is an #include line which says #include “MyFile.generated.h”]. This is a header file which doesn’t exist until it is built by the unreal build tool (UBT). The location of this generated header file is going to be within the intermediate folder. The generated header file is created every time you build the header file, so don’t modify it manually because your changes will get overwritten.
When you build the project, here is what happens:
3.0: A project build has been initialized
3.1: The unreal build tool (UBT) will parse all of your header files and look for and expand UE4 specific macros (such as UPROPERTY(), UCLASS(), UENUM, GENERATED_BODY(), etc). UBT doesn’t care about whether or not a file is a part of your solution, it will use every file it finds to build your project. Based on the properties you set for each macro, the generated header file will reflect these values. If there are any errors, the visual studio output log will display the UE4 build errors. This is what the unreal team calls “Reflection”, which shares similarities to C# reflection.
3.2: Once the UE4 generated file build completes, visual studio will build the binary executable files and launch & load them within the game editor.
If you are using source control, such as perforce:
4.0: If the file is brand new to the project, you’ll just want to use p4v to add the file to version control.
4.1: If the file has been modified, you’ll just want to push the changes.
4.2: If you want to move the file to another folder, here’s where it gets tricky! You have to use PERFORCE to move the file (NOT windows explorer). Next, you will probably want to update the visual studio solution explorer to reflect the updated file location. The one-file solution is to just remove the file from the solution and then re-add it using “Add existing file to solution”. The large, multi-file solution is to delete the project file and let the engine rebuild it by launching the editor and inserting a temporary class and opening it up in the editor (there’s gotta be a better way to do this…).
If you are manually creating a header file from scratch, the UBT has some picky requirements on formatting:
-The class must inherit from UObject or a derived class.
-The class name must be prefixed with the capital letter of the object you’re inheriting from, so “AMyClass : public AActor”, or “UMyClass : public UObject”
-You must include an API reference, with the following format: [Projectname]_API between the class keyword and the class name
-Every class should include “GENERATED_BODY()” as the very first line within the class body
-Every class should also use UCLASS() as an attribute macro above the class definition
-The class name should match the name of the header file, minus the prefix
-you must have #pragma once at the very top of the .h file
-You must include a link to the generated header file the UBT builds (ie: #include “MyClass.generated.h”)
So: you should have something like this:
class [YOURPROJECTNAME]_API UMyClass : public UObject
Note: If your file doesn’t actually use any of the UE4 macros, the UBT will not create a generated .h file. This will cause your build to fail.