.Class on FClassFinder Returns TSubclassOf<UUserWidget> and here is my solution

Hey after i digged FClassFinder on UE4 Docs here I show my code to do challenge. I used GetDefaultObject() to get UClass and after that casted though UUserWidget to assign field.

I wonder if I am correct or not. Will get that answer after watch the video right now.

UPuzzlePlatformsGameInstance::UPuzzlePlatformsGameInstance()
{
	ConstructorHelpers::FClassFinder<UUserWidget> MenuClassWidget(TEXT("/Game/MenuSystem/WBP_MainMenu"));
	if (!ensure(MenuClassWidget.Class != nullptr)) return;
	UE_LOG(LogTemp, Warning, TEXT("Found class %s"), *MenuClassWidget.Class->GetName());
	MenuClass = Cast<UUserWidget>(MenuClassWidget.Class->GetDefaultObject());

}

After i watch the video, the type of MenuClass was TSubClassOf. I wonder if were did a mistaken. @sampattuzzi

I don’t understand the question here.

no question at all. I show my challenge solution.

1 Like

Privacy & Terms