I have Actor with UActorComponent and UWidgetComponent.
In BeginPlay() within my ActorComponent I want to get UUserWidget which I setted in UWidgetComponent:
AActor* owner = GetOwner();
UWidgetComponent* w = Cast<UWidgetComponent>(owner->GetComponentByClass(UWidgetComponent::StaticClass()));
screen_w = Cast<UMyScreenWidget>(w->GetUserWidgetObject());
if (!screen_w )
UE_LOG(LogTemp, Error, TEXT("cannot get screen_widget"))
w is non zero and w-GetUserWidgetObject() is 0. It works fine in 4.19. Widget is setted, I can see him in editor.
Yes, this is in BeginPlay().
I checked sequence and it turned out that first called this BeginPlay()
then Initialize() and NativeConstruct() of my widget. That is the problem.
How can I fix this?
I have two components and one depends on another and must wait for him.
Is there any build in sync methods? Or I just use Tick() function until widget is ready?