In code below im trying to create Widget and add it to ScrollBox. Problem is, I can’t because Item is nullptr. What have I done wrong?
void UInventoryWidget::InventoryInitalize(UInventoryComponent* InventoryLocal)
{
InventoryBox->ClearChildren();
for (const UUItem* ItemHere : InventoryLocal->Items)
{
UInventoryItem* Item = CreateWidget<UInventoryItem>(GetWorld(), InventoryItemClass);
if (IsValid(Item))
{
InventoryBox->AddChild(Item);
}
else
{
UE_LOG(LogTemp, Warning, TEXT("Null"));
}
}
}