[C++] How to use exposed on spawn variables in widget

This line

UBlabla blabla_widget = CreateWidget<UBlabla>((), UBlabla::StaticClass());

Creates the widget. But how can I put to constructor exposed on spawn variables?
Only manually?

blabla_widget->exp_a = 0;
blabla_widget->exp_b = 1;

~

blabla_widget->SetBlablaVariables(0, 1);

Or there are some more pretty ways to do it?

1 Like

I’m having the same problem.

There no way to do it automatic, using spawn function. Good workaround is to create your own spawn function or maybe do a some C++ macro :slight_smile:

I’ve been doing this lately and my solution was to just create a function to run after setting my variables.
In my case I’m using a BlueprintImplementableEvent called InitializeWidget() which runs code I would generaly do in the OnConstruct event.

UBlabla blabla_widget = CreateWidget<UBlabla>((), UBlabla::StaticClass());

TestVar1 = 0;
TestVar2 = true;

InitializeWidget();