ShooterGame Headers cleanliness

I’m just wondering how can it be so clean? When I try to follow ShooterExample my headers gonna get messy quite fast. For example for SShooterMenuWidget.h I need to include ShooterGame_Menu.h before SLATE_ARGUMENT(ShooterGame_Menu*, GameModeOwner) works. Also I need to keep making relative paths …/…/ etc. But in ShooterGame Example we can see that there is not that kind of trickery. I’m wondering If ShooterGame.Build.cs has something to do with it. Cause there is PricateIncludePaths.AddRange… But haven’t got it working for me yet.

I believe this mostly comes down to the inclusion of two automatically generated headers in the ShooterGame.h precompiled header (which by virtue of being the precompiled header, is necessarily included in every translation unit):

#include "ShooterGameClasses.h"
#include "ShooterGameComponentClasses.h"

If you look at ShooterGameClasses.h, you’ll see the following:

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
	C++ class boilerplate exported from UnrealHeaderTool.
	This is automatically generated by the tools.
	DO NOT modify this manually! Edit the corresponding .h files instead!
#pragma once

#include "C:/...]/Documents/Unreal Projects/ShooterGame/Source/ShooterGame/Classes/Bots/BTTask_FindPickup.h"
#include "C:/...]/Documents/Unreal Projects/ShooterGame/Source/ShooterGame/Classes/Bots/BTTask_FindPointNearEnemy.h"
**#include "C:/...]/Documents/Unreal Projects/ShooterGame/Source/ShooterGame/Classes/Online/ShooterGame_Menu.h"**

Yes I almost forgot those headers. Can someone say how to generate those headers?

The file always appears to be generated - my project based on the third-person C++ template has a “[ProjectName]Classes.h” file at “Intermediate\Build\Win64\Inc[ProjectName]” - however, the file is essentially empty for me (containing only the header comment and #pragma once directive). Its contents are probably based on your files being organized into the “Classes” directory structure like the ones in the ShooterGame example are. If you’re doing that already, then you may find you’re just able to include the auto-generated header already.

However, I’m not convinced this is a good idea. It’s somewhat convenient and more similar to the UnrealScript way of working, but it also means that modifying any of those headers is going to result in a complete rebuild of your project. In my case, an incremental build + link is generally twice as fast as a full rebuild, and I would hesitate to give that up just to save some typing with #include directives.

Right now all of my project’s files are located in the same directory, but in the event I needed to start breaking them up into subdirectories for the sake of organization, I would probably look into adding those subdirectories to the INCLUDE_PATH. That’s probably achieved through the *.Build.cs scripts, as you alluded to in your original post, although I’m not sure how it’s done.