Download

How to create a widgetcompnent then added to a actor class?

Hello,
every elite, I am trying to Create a UWidgetComponent object(3D menu in a world) and attach it to a actor, i am wondering how to set a userWidget by this UWidgetComponent object? This is my code, is this right?
{
Widget = CreateDefaultSubobject<UWidgetComponent>(TEXT(“widgetComponent”));

Widget-&gt;SetupAttachment(RootComponent);

Widget-&gt;SetDrawSize(FVector2D(1863, 1100));		

Widget-&gt;SetRelativeScale3D(FVector(0.35, 0.35, 0.35));

//Widget-&gt;SetMaterial(0,)
Widget-&gt;SetBlendMode(EWidgetBlendMode::Masked);

CurrentWidget = CreateWidget&lt;UMenu3DUserWidget&gt;(GetWorld());
// 	UMyUserWidget *userWidget = CreateWidget&lt;UMyUserWidget&gt;(GetWorld());

Widget-&gt;SetWidget(CurrentWidget);
Widget-&gt;SetTwoSided(true);

}