I am creating Inventory system in C++, whole functionality works fine but I have problem with weird fatal error ,Invalid object in GC" which I got randomly. Sometimes I can play the game like 1 hour, do crazy things with inventory and all works fine. Sometimes I can only press the play button and this error shows up.
[Line: 903] Invalid object in GC:
Property Name: Thumbnail, Offset: 40,
It looks like problem with InventoryComponent - FInventoryStructure contains UTexture2D* Thumbnail property, but I dont know whats wrong. Its defined this way:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Item details") UTexture2D* Thumbnail;
All looks like this:
- I have FInventoryStructure (item name, description etc) and FSlotItem (contains FInventoryStructure property and info about quantity)
- I have InventoryComponent, which contains information about inventory (name, description, number of slots etc) and TArray of the FSlotItem. At Begin play I initialize TArray of FSlotItem like this:
Then Additem method:
I tried to set nullptr in deleteItem method and NULL, both same issue…
And then I Have PlayerInventoryWidget which contains CreateInventory (called if player first time open inventory) and UpdateInventory methods
And at the end UInventoryItemWidget containts binding binding on UImage (imgItemThumnail) and UpdateItem method:
Somebody know what can throw this error? Or is there way how to do this better?