The struct just exsit,But the visual studio just report Unrecognized type -type must be a UCLASS,USTRUCT, or UENUM,I just have import the .h.But why it can’t find the struct?
Thats UnrealHeaderTool error and it happens when it search header files for reflection system macros like USTRUCT, UCLASS etc. and in UPROPERTY or UFUNCTION there is not supported type by unreal reflection system or type that UHT didn’t find to be reflected (missing USTRUCT)
If you can, paste header files with value that error complains about and with decleration of struct you trying to use, so we can try to help you ferther. Remember to use code formatting when you paste code here
H1Z1Character.h
#include "CoreMinimal.h"
#include "H1Z1Character.h"
#include "Interact.h"
#include "GameFramework/PlayerController.h"
#include "MyPlayerController.generated.h"
USTRUCT(BlueprintType)
struct FInventoryItem : public FTableRowBase { //ERROR: I have defined the struct here.But the visual studio can't find.
GENERATED_BODY()
public:
FInventoryItem() {
Name = FText::FromString("Item");
Action = FText::FromString("Use");
Description = FText::FromString("Please enter a description for this item");
Value = 10;
}
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FName ItemID;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
TSubclassOf<class APickup> ItemPickup;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FText Name;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FText Action;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
int32 Value;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
UTexture2D *Thumbnail;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
FText Description;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FCraftingInfo> CraftCombinations;
UPROPERTY(EditAnywhere,BlueprintReadWrite)
bool bCanBeUsed;
bool operator ==(const FInventoryItem &Item) const {
if (ItemID == Item.ItemID) {
return true;
}
else {
return false;
}
}
};
};
Oh,god ! The code is too much, i just didn’t give the unimportant code,I have make a notice to make you easily to find it,I hope you will my hero,Thank you again.
Frist,Thank you for help. the following is my code:
MyPlayerController.h
#include “CoreMinimal.h”
#include “H1Z1Character.h”
#include “Interact.h”
#include “GameFramework/PlayerController.h”
#include “MyPlayerController.generated.h”
/**
*
*/
UCLASS()
class H1Z1_API AMyPlayerController : public APlayerController
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable,Category = "Utils")
void AddItemToInventoryById(FName ID);
UPROPERTY(BlueprintReadWrite,VisibleAnywhere)
AInteract * CurrentInteractable;
UPROPERTY(BlueprintReadWrite,VisibleAnywhere)
TArray <FInventoryItem> Inventory; // ***ERROR:Uncongnized type FInventory, type must be a USTRUCT,UCLASS,UENUM.***
protected:
void Interact();
virtual void SetupInputComponent() override;
};