I think you only need to include two things in the header file:
generated.hfile (only if you have defined UCLASSes, USTRUCTs, or UENUMs).
- The header of any parent class of classes defined in the file
If it’s not one of the cases above, and you have a property in your header whose type hasn’t been included yet, you can do what’s called forward declaration. Like this:
class UMaterialInterface* Material;
void SetMyMaterial(class UMaterialInterface* NewMaterial);
you could also do one forward declaration for the whole file by putting it outside any class declarations, like:
Forward declaration is telling the compiler that it should treat
UMaterialInterface as a class, even though it hasn’t been included yet.
Keep as many of your
#includes as possible in the cpp file instead of the header. It improved compile times.