CreateWidget called with a null class Error

Why not just set the InventoryCellClass by hand in the editor? Hard coding assets into a system is never a good idea in my book. Also, I’m not sure if you are trying to use NativeOnConstruct as if it was the “constructor” of your class. Because as far as I know, NativeOnConstruct is called when you are creating the widget at runtime, after the widget has been constructed.



// InventoryWidget.h

public:

     /** Widget constructor. */
     UInventoryWidget(const FObjectInitializer& ObjectInitializer);

protected:

     /** Class to use for inventory cells. */
     UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Parameters")
     TSubclassOf<UInventoryCell> InventoryCellClass;




// InventoryWidget.cpp

UInventoryWidget::UInventoryWidget(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
     // You can give the TSubclassOf variable a default class to use like this.
     InventoryCellClass = UInventoryCell::StaticClass();
}