Parsing widget from bp as TSharedPtr

Hi I am trying to parse/create a TSharedPtr to a c++ function from blueprint, I have not used shared pointers before and have no clue on how to accomplish this.

//.cpp

void UStaticBPLibrary::ShowLoadingScreen(TSharedPtr<SWidget> inWidget)
{
	FLoadingScreenAttributes LoadingScreen;
	LoadingScreen.WidgetLoadingScreen = inWidget;
	GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}

//.h

UFUNCTION(BlueprintCallable, Category = Loading)
static void ShowLoadingScreen(TSharedPtr<class SWidget> inWidget);

Error:

Unrecognized type 'TSharedPtr' - type must be a UCLASS, USTRUCT or UENUM

Passing in a UUserWidget* and using TakeWidget(); solved this for me :slight_smile:

void UStaticBPLibrary::ShowLoadingScreen(UUserWidget* inWidget)
{
	FLoadingScreenAttributes LoadingScreen;
	TSharedPtr<SWidget> WidgetPtr = inWidget->TakeWidget();
	LoadingScreen.WidgetLoadingScreen = WidgetPtr;
	GetMoviePlayer()->SetupLoadingScreen(LoadingScreen);
}
1 Like