Hi. I am working on transferring the Blueprint to CPP about UserWidget.
However, I continued to experience problems while using AddToViewPort(), so I asked a question.
It’s my BP about AddToViewPort.
for (int i = 0; i < 5; i++)
{
FST_InventoryCPP NewEmptyInventoryItem;
Inventory.Add(NewEmptyInventoryItem);
}
TArray<UUserWidget*> FoundWidgets;
UWidgetBlueprintLibrary::GetAllWidgetsOfClass(GetWorld(), FoundWidgets, UBM_InventoryContainer::StaticClass(), false);
for (UUserWidget* Widget : FoundWidgets)
{
UBM_InventoryContainer* InventoryContainerWidget = Cast<UBM_InventoryContainer>(Widget);
if (InventoryContainerWidget)
{
UBM_InventoryContainer* newInv = CreateWidget<UBM_InventoryContainer>(GetWorld(), UBM_InventoryContainer::StaticClass());
newInv->AddToViewport();
UE_LOG(LogTemp, Warning, TEXT("Is IT GOOD?"));
}
}
It’s my CPP code and It’s BeginPlay() func.
I set my custom widget’s visbiliy to visible too.