doneykoo
(doneykoo)
January 9, 2018, 3:20am
1
I have a TSoftObjectPtr UIBlueprint property.
It refers to the asset:
WidgetBlueprint’/Game/UI/BP_PickupInfoFloatUI_Weapon.BP_PickupInfoFloatUI_Weapon’
However when I load the asset by UIBlueprint.Get() , called during BeginPlay() of an actor component.
it only works in Editor, returning a valid UBlueprint * pointer.
But it always fails in packaged build, returning a nullptr .
How to solve it?
doneykoo
(doneykoo)
January 9, 2018, 9:07am
2
update: I’ve tried following the approach in Unreal Doc: Referencing Assets | Unreal Engine, using codes as:
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category=Building)
TSoftObjectPtr<UStaticMesh> BaseMesh;
UStaticMesh* GetLazyLoadedMesh()
{
if (BaseMesh.IsPending())
{
const FSoftObjectPath& AssetRef = BaseMesh.ToStringReference();
BaseMesh = Cast< UStaticMesh>(Streamable.SynchronousLoad(AssetRef));
}
return BaseMesh.Get();
}
But still, the asset is only loaded successfully in editor play. While fails by just returning a nullptr in packaged game play.
Noowai
(Noowai)
January 28, 2018, 8:28pm
3
I double this question! Been onto it since 4.16, but no luck on how async load should work with c++ yet
nande
(nande)
December 2, 2024, 5:31am
4
you need to load it.
Using LoadSynchronous() this works in ue 5+