Animation Blueprint load failed in packaged build

AlphaBrox
Sun, 02 Jul 2023 11:11:27 +0000
C++

Hello.
Please, help with the next situation (UE 5.2): I load skeletal mesh & animation blueprint in C++ by soft pointers. Everything is ok in the Editor, but animation blueprint load failed in packaged build (skeletal mesh load is ok everywhere).

// take struct from datatable
FLegsData* LegsData = LegsRow.DataTable->FindRow<FLegsData>(LegsRow.RowName, "", false);

TArray<FSoftObjectPath> SoftPaths;
TSoftObjectPtr<USkeletalMesh> LegsSkelMesh;
TSoftObjectPtr<UAnimBlueprint> LegsAnimBp;

if (!LegsData->SkelMesh.IsNull())
{
	LegsSkelMesh = LegsData->SkelMesh;
	SoftPaths.Add(LegsData->SkelMesh.ToSoftObjectPath());

	if (!LegsData->AnimBp.IsNull())
	{
		LegsAnimBp = LegsData->AnimBp;
		SoftPaths.Add(LegsData->AnimBp.ToSoftObjectPath());
	}
}

if (!SoftPaths.IsEmpty())
{
	TSharedPtr<FStreamableHandle> Handle = UAssetManager::Get().GetStreamableManager()
	.RequestAsyncLoad(SoftPaths, [this, LegsSkelMesh, LegsAnimBp]()
    {
        // its ok in editor and packaged build
		if (!LegsSkelMesh.IsNull())
			GetMesh()->SetSkeletalMeshAsset(LegsSkelMesh.Get());

		if (!LegsAnimBp.IsNull()) // ok
		{
			if (LegsAnimBp.Get()) // <--- false in packaged build!
			{
				if (LegsAnimBp.Get()->GetAnimBlueprintGeneratedClass())
				{				GetMesh()->SetAnimInstanceClass(LegsAnimBp.Get()->GetAnimBlueprintGeneratedClass());
				}
			}
		}
	});
}

Maybe there is another ‘true-way’ to async load soft-ptr assets? All I need is async load and use soft-ptr skeletal mesh and after that async load and apply soft-ptr anim-bp for this skeletal mesh.

7 posts - 3 participants