Hi All,
I experienced something strange. All this time, I used C++ to create and show/hide widget.
I used the following code:
FStringAssetRef AssetRef("WidgetBlueprint'/Path/To/BPWidget'");
UObject* SyncResult = StreamableManager.SynchronousLoad(AssetRef);
UBlueprint* WidgetBP = Cast<UBlueprint>(SyncResult);
UUserWidget* UIWidget = CreateWidget<UUserWidget>(GetWorld(), WidgetBP->GeneratedClass);
When I played it in editor (both in selected viewport and standalone game), everything seems fine.
Then I packaged the game.
I tried the game and nothing wrong with the gameplay. However, when I click something to show UI, the game crashed. After I re-packaged with some modification, I found that it got crashed when calling the SynchronousLoad (line 2 in the code above).
How can I fix this error? I noticed there are, at least two safer way to create widget:
- From Blueprint and store the reference to C++ variable
- Using TSubclassof variable and then set it in the Defaults
Since I think the issue here is also error with the SynchronousLoad, I want to know if there is a way to make it safe for packaging.
Thank you in advance for all your help.
Regards,
Ismail