TSubclassOf returning as object Class in blueprints

Hello,
So I have been trying to make an inventory system and to do this I have basically set up a USTRUCT for each slot in my inventory which looks like this:

    USTRUCT(BlueprintType)
    struct FItemSlot {
    
    	GENERATED_BODY();
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
    		int32 Quantity;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
    		TSubclassOf<class AItemBase> Item;
    
    };

Now I have to make the graphical portion, which I have decided to do in Blueprints. When I break this struct in blueprints though, I the TSubclassOf is a class type and not a reference type:

99290-itemdefaults1.png

This would be fine, accept when I Get Class Defaults, it does not return The UTexture2D* that I have set up in my ItemBase class. I am not sure if this is because it is a pointer type? Here is my Item Base.h:

UCLASS()
class HORRORGAME_API AItemBase :  AActor
{
	GENERATED_BODY()
	
:	
	// Sets default values for this actor's properties
	AItemBase(const FObjectInitializer& ObjectInitializer);

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		USkeletalMeshComponent* Mesh;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Item)
		UTexture2D* Image;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		FString Name;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		bool bStackable;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		EItemTag tag;
	
};

And Here is what happens when I get class Defaults:

99290-itemdefaults1.png

By the way, all of my items are blueprints of ItemBase currently, but in the future I will be making the blueprints of ItemWeapon, etc.

Any help is appreciated

Did you try it as a raw pointer, just to rule our if you can have a TSubClassOf in a UStruct?

AItemBase* Item;

I realize that isn’t ideal, but I’ve had issues with TSubClassOf.

Hey -

As explains in the post below, the GetClassDefaults node does not expose object reference values.
New 4.9 Get Class Defaults node doesn't have all the variables - Programming & Scripting - Epic Developer Community Forums . For example, if the pointer (*) is replaced with TSubclassOf for your UTexture2D you will instead get a class reference pin on the GetClassDefaults node.

Cheers

Okay,
This makes sense, except I am going to need the UTexture2D as a reference later anyways, so is there another way I could have the same effect as a TSubclass<> (namely so I could use blueprints, I can cast the rest) but also return a reference to the class and not the class itself?

The raw pointer does work, but all of my items will be blueprints of sub-classes of AItemBase, therefore if I cannot just pass a blueprint reference in, unless there is a way to do this I am unaware of?

Okay, so I believe I have found the simple way to fix this problem is to actually have a variable UTexture2D in my USTRUCT and then in the constructor just set it to the the ItemBase Image. It seems to work pretty well, and is probably cheaper than the other method I thought of as spawning the actor creating separate variables and then destroying it.

For future reference this is what I have done:

USTRUCT(BlueprintType)
struct FItemSlot {

	GENERATED_BODY();

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		int32 Quantity;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		TSubclassOf<AItemBase> Item;

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Info)
		UTexture2D* Item_Image;

	FItemSlot(){
		if (Item->IsChildOf(AItemBase::StaticClass())) {
			Item_Image = Cast<AItemBase>(Item)->Image;
		}
	}

};