So the class DOES know the ETeam enum but not in combination with with a UFUNCTION macro⊠After a lot more testing I found out that using a manual include in the AmmoReserve.h fixes it:
include âEnums.hâ
So it seems that for UFUNCTION the UE4 headertool (or whatever tool is used) does NOT check the global project header:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Engine.h"
#include "UnrealNetwork.h"
// Custom includes
#include "Lib.h"
#include "Enums.h" // <<<<<<<<<<<<<<<<<<<<<<< included here! Why do I still require a manual include...
#include "Structs.h"
#include "GameStatics.h"
// Custom Macro's
//<snip>
When you create a new class, the source file for the class includes the projectâs header file but the class header does not have this include statement. If you have your Enum in its own class that is included in your project header, you will need to add an include statement for either the Enum class or the project header to the new class header.
but the class header does not have this include statement
Then why does it work for UPROPERTY if it doesnât even know the enum at all? Because it seems it does know it and it seems it does somehow include the project-header-file (which contains the enums and such) because otherwise UPROPERTY can not work right? Same for structs and everything, those also work.
Itâs just UFUNCTION + enum in global class + project header include = compiler error. Any other combinations work including structs.
UPROPERTY + enum in global class + project header include = works fine.
enum in global class + project header include = works fine.
UFUNCTION + struct in global class + project header include = works fine.
Etc.
Because of this extremely rare exception to the rule, I find it so hard to believe that this is intended behavior. And if it is intended, can someone perhaps explain me the design reasons behind this?
Iâm sorry, I misunderstood the question. I didnât realize you were referring to the difference in behavior. I have entered a bug report, UE-31308 , for investigation.
Basically the Struct (located in another file and included through the project-header) is valid and works in both blueprints and C++. But the moment I put it in a UPROPERTY.
UE-31308 was closed as Wonât Fix on February 5th.
Weâve encountered numerous varieties of this âtype must be a UCLASS, USTRUCT or UENUMâ problem when it is correctly included. We would like to see this fixed.
This issue was initially closed due to inactivity on the bug. I have reopend the report added a note that this is still affecting people to provide more visibility to the issue.
Ran into the same situation right now. Cause of circular dependencies i had to move the header include inside the MyGame.h. Had never had problems with it before. Kinda sucks, have to find a way around it. Just dont want to mess up the classes with all the structs and enums.