Hi,
I’ve been searching around regarding an issue I’m having with USTRUCTS, none of the solutions from the other threads were helpful. My structs are, for some reason, not getting included in my header file when explicitly included as their own file (
#include "Structs.h"
).
It’s not possible for me to define these structs in the same file as they are reused in other header files and need to be included there too.
These are the code files in question:
Item.h:
#pragma once
#include "CoreMinimal.h"
#include "../Topdown0.h"
#include "UObject/NoExportTypes.h"
#include "../Interfaces/InteractInterface.h"
#include "Engine/DataTable.h"
#include "Item.generated.h"
class UInventoryComponent; // Forward declaration
/*
* Item data class
*/
UCLASS(Abstract, BlueprintType, Blueprintable, EditInlineNew, DefaultToInstanced)
class TOPDOWN0_API UItem : public UObject, public IInteractInterface
{
GENERATED_BODY()
public:
UItem();
virtual class UWorld* GetWorld() const { return World; };
UPROPERTY(Transient)
class UWorld* World;
/* Text for item action (Equip, Eat, etc.)*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
FText UseActionText;
/* Mesh to display for this item's pickup */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
class UStaticMesh* PickupMesh;
/* Thumbnail for this item */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
class UTexture2D* Thumbnail;
/* Display name for this item in the inventory */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item")
FText ItemDisplayName;
/* (OPTIONAL) Description for this item */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item", meta = (MultiLine = true))
FText ItemDescription;
/* Weight of this item */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Item", meta = (ClampMin = 0.0))
float Weight;
/* Inventory that owns this item */
UPROPERTY()
class UInventoryComponent* OwningInventory;
virtual void Use(class ATopdown0Character* Character);
UFUNCTION(BlueprintImplementableEvent)
void OnUse(class ATopdown0Character* Character); // Blueprint event
/*
* InteractInterface functions
*/
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category="Interaction")
void OnInteract(AActor* Interactor);
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
void StartFocus();
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Interaction")
void EndFocus();
/* ItemStruct */
FItemStruct ItemStructure; // Getting " 'ItemStructure': unknown override specifier " here.
};
Structs.h:
#pragma once
#include "../../Item.h"
#include "Structs.generated.h"
USTRUCT(BlueprintType)
struct TOPDOWN0_API FItemStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FName ItemID;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FText ItemName;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
UTexture2D* ItemThumbnail;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FText ItemDescription;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FString ItemType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (Tooltip = "CHANGE LATER FOR OWN STRUCT"))
float Damage;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (Tooltip = "CHANGE LATER FOR OWN STRUCT"))
float Defense;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
bool IsStackable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
bool IsConsumable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
int32 MaxStackSize;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
float Durability;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
int32 SellPrice;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
class UItem* Class;
FItemStruct():
ItemThumbnail(nullptr), Damage(0), Defense(0), IsStackable(true), IsConsumable(true), MaxStackSize(4),
Durability(0), SellPrice(0), Class(nullptr) {}
};
USTRUCT(BlueprintType)
struct TOPDOWN0_API FSlotStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
FItemStruct ItemStruct;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "InventorySlot")
int32 Quantity;
FSlotStruct():
Quantity(0) {}
};
I’ve tried to directly include the **Structs.h **file in the header, still the same outcome.
Any clues on how to solve this issue?