I have declared UWidgetComponent in my header file like this:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="CellWidget")
TSubclassOf<UWidgetComponent> CellWidgetComponent;
I would like to access my UCellWidget from this component but GetWidgetClass and GetUserWidgetObject return null.
UWidgetComponent* WidgetComponent = Cast<UWidgetComponent>(CellWidgetComponent->GetDefaultObject());
if(WidgetComponent)
UE_LOG(LogTemp, Warning, TEXT("WidgetComponent is not null"));
if(WidgetComponent->GetWidgetClass())
UE_LOG(LogTemp, Warning, TEXT("WidgetComponent->GetWidgetClass() is not null"));
if(WidgetComponent->GetUserWidgetObject())
UE_LOG(LogTemp, Warning, TEXT("WidgetComponent->GetUserWidgetObject() is not null"));
return Cast<UCellWidget>(WidgetComponent->GetUserWidgetObject());
What should I do to access my UCellWidget from this component?