Im attempting to create a userwidget component and it works and is added to the component but isnt visible in game, but if I run the game and change the size or another value of the component through the editor while the game is running it becomes visible and works as expected. Any ideas on how I can get it to show on start up like it should?
void ADroppedItem::AddDroppedUI()
{
DroppedUIWidget = NewObject<UWidgetComponent>(this,UWidgetComponent::StaticClass(), TEXT("DropUI"));
if(DroppedUIWidget && PlayerHUD)
{
TSubclassOf<UUserWidget> CastWidget = PlayerHUD->GetDroppedWidgetClass();
if(CastWidget)
{
DroppedUIWidget->SetWidgetClass(CastWidget);
DroppedUIWidget->AttachToComponent(GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
DroppedUIWidget->SetDrawAtDesiredSize(true);
DroppedUIWidget->RequestRedraw();
}
PlayerHUD->AddToDroppedArray(this);
}
}