Hello,
I’m working on a plugin that import a StaticMesh into the Content Browser (not runtime) but the import does not seem to work. ![]()
The file Mesh.uasset is created in Content\MyMeshFolder but it is only 1Ko and is not readable by the engine
This is the first time I made an fbx import in C++, I do not think I’m using the right method and I do not see how to do this
This is my current code
FReply SBlenderImporterAssetSlate::ImportButtonClicked()
{
UE_LOG(LogTemp, Warning, TEXT("Start"));
UnFbx::FFbxImporter* FbxImporter = UnFbx::FFbxImporter::GetInstance();
if (FbxImporter->ImportFromFile(FbxPath, TEXT("fbx")))
{
UE_LOG(LogTemp, Warning, TEXT("ImportFromFile success"));
TArray<FbxNode*> FbxMeshArray;
FbxImporter->FillFbxMeshArray(FbxImporter->Scene->GetRootNode(), FbxMeshArray, FbxImporter);
UFbxStaticMeshImportData* ImportData = NewObject<UFbxStaticMeshImportData>(GetTransientPackage(), "MyImportData", RF_NoFlags, nullptr);
ImportedMesh = FbxImporter->ImportStaticMeshAsSingle(GetTransientPackage(), FbxMeshArray, "MyMesh", RF_Public, ImportData, ImportedMesh);
if (ImportedMesh->GetFullName() != "None")
{
UE_LOG(LogTemp, Warning, TEXT("ImportStaticMeshAsSingle success"));
UPackage* Package = CreatePackage(NULL, TEXT("/Game/MyMeshFolder/Mesh")); //Create package if not exist
Package->FullyLoad(); //Load full package for import
Package->MarkPackageDirty(); // Mark package dirty to be able to save it
FAssetRegistryModule::AssetCreated(ImportedMesh); //Notifies registry of new asset in-memory
FString PackageFileName = FPackageName::LongPackageNameToFilename(TEXT("/Game/MyMeshFolder/Mesh"), FPackageName::GetAssetPackageExtension());
bool bSaved = UPackage::SavePackage(Package, ImportedMesh, EObjectFlags::RF_Public, *PackageFileName, GError, nullptr, true, true);
if (bSaved == true)
{
UE_LOG(LogTemp, Warning, TEXT("Saved package"));
}
}
}
return FReply::Handled();
}
And this the Output Log
LogTemp: Warning: Start
LogSlate: Took 0.000287 seconds to synchronously load lazily loaded font '../../../Engine/Content/Slate/Fonts/Roboto-Light.ttf' (167K)
LogFbx: Loading FBX Scene from G:\SM_SuzanneLod0.fbx
LogFbx: FBX Scene Loaded Succesfully
LogTemp: Warning: ImportFromFile success
LogFbx: Warning: Triangulating static mesh SuzanneLod0
LogFbx: Warning: Warning: The imported mesh is very small. This is most likely an issue with the units used when exporting to FBX.
LogTemp: Warning: ImportStaticMeshAsSingle success
LogSlate: FSceneViewport::OnFocusLost() reason 2
LogSavePackage: Save=50.57ms
LogSavePackage: Moving '../../../../../../Projet perso/Unreal Projects/Marketplace/Blender For Unreal Import/Engine 4.19/Saved/Mesh6F4104AB4DB366300413F78EB2E07A03.tmp' to '../../../../../../Projet perso/Unreal Projects/Marketplace/Blender For Unreal Import/Engine 4.19/Content/MyMeshFolder/Mesh.uasset'
LogSavePackage: Display: Finished SavePackage ../../../../../../Projet perso/Unreal Projects/Marketplace/Blender For Unreal Import/Engine 4.19/Content/MyMeshFolder/Mesh.uasset
LogTemp: Warning: Saved package
Thank you for your help, Xavier.