I have a struct that I made called FInventorySlot. It needs to have two properties, one is an integer and the other is the class of a blueprint called BP_PickUpItem_MAIN. It is not a c++ class and inherits from another blueprint class called interactable which is also not a c++ class. Interactable then inherits from AActor.
I am aware of the issue of trying to use blueprint created classes in C++ but I figure this might be different due to the fact that I just need the class.
I’m having an issue setting the class property inside the constructor with FObjectFinder. When it is inside the constructor and has been built it crashes when any blueprint graph is opened. Here is some code for my struct:
USTRUCT(BlueprintType)
struct FInventorySlot
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory")
TSubclassOf<UObject> ItemClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Inventory")
int32 StackAmount;
FInventorySlot()
{
static ConstructorHelpers::FObjectFinder<UClass> BlueprintClass(TEXT("Class'/Game/Evolution/Actors/Pickups/BP_PickUpItem_MAIN.BP_PickUpItem_MAIN'"));
ItemClass = BlueprintClass.Object;
StackAmount = 1;
}
};
The code for the struct works perfect when I comment out the top two lines of my FInventorySlot constructor. How can I change the class dynamically like this of a structure?