Hi, I’ve been struggling with this for quite some time now and I had no success solving it. I had this exact same problem with the exact same file and include but I don’t remember how I fixed it.
The compiler says “Unrecognized type ‘FInvItem’ - type must be UCLASS, USTRUCT or UENUM”
this is the code where the error occurs:
Pickup.h:
public:
UPROPERTY(EditAnywhere, Category="Item Info")
FInvItem itemInfo;
Pickup.h has the following includes:
#include "Interactable.h"
#include "ItemsDB.h"
#include "Pickup.generated.h"
ItemsDB.h (is way bigger than this)
USTRUCT(BlueprintType)
struct FInvItem
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
int32 itemID = 0; //ID of the item in the items DB
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
int32 usesLeft = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
FConsumable consumableInfo;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
FWeapon weaponInfo;
/*UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item Info")
UCommonWidget* slotWidget;*/
};
ItemsDB.h has the following includes:
#include "Engine/DataAsset.h"
#include "GameCharacter.h"
#include "CommonWidget.h"
#include "Pickup.h"
#include "ItemsDB.generated.h"
I think I solved this problem before with forward declaring the ItemsDB in Pickup.h like this:
class UItemsDB;
but if I do this (the forward declaring of ItemsDB class in Pickup.h) now the GameCharacter.h gives me a bunch of errors related to structs from ItemsDB.h
Here are the includes in GameCharacter.h
#include "GameFramework/Character.h"
#include "Engine.h"
#include "ItemsDB.h"
#include "CommonWidget.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "Pickup.h"
#include "GameCharacter.generated.h"
Thanks in advance!