I am trying to save an existing static mesh object to disk. The saving itself is working, however the created asset itself is not showing up in the content browser, even after a refresh (manual or by code).
This is the simplified code, currently used within a Blueprint function library. What is missing there or what might be wrong?
bool UStaticMeshFromProceduralMesh::SaveStaticMeshToDisk(UStaticMesh* StaticMesh, const FString& FileName)
{
FString PackageName = FString::Printf(TEXT("/Game/%s"), *FileName);
UPackage* Package = CreatePackage(*PackageName);
StaticMesh->Rename(*StaticMesh->GetName(), Package);
StaticMesh->MarkPackageDirty();
FString PackageFileName = FPackageName::LongPackageNameToFilename(PackageName,
FPackageName::GetAssetPackageExtension());
bool bSaved = UPackage::SavePackage(
Package, StaticMesh, EObjectFlags::RF_Public | RF_Standalone, *PackageFileName, GError, nullptr, true, true, SAVE_NoError);
return bSaved;
]
I tried to use it with the SavePackageArgs as well, but there I get the same result - asset is saved on disk, but not visible in content browser
FSavePackageArgs SaveArgs;
SaveArgs.TopLevelFlags = EObjectFlags::RF_Public | RF_Standalone;
SaveArgs.Error = GError;
SaveArgs.SaveFlags = SAVE_NoError | SAVE_KeepGUID;
// Save the package
bool bSaved = UPackage::SavePackage(
Package,
StaticMesh,
*PackageFileName,
SaveArgs
);