I’m working on a small importer but I wanna to auto-add the mesh to the current open scene.
I’ve imported it with
FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
TArray<UObject*> ImportedObjects = AssetToolsModule.Get().ImportAssets(files, packagePath);
and it gets into the library flawlessly but unfortunatly I didn’t manage the way to place it into the editor
I’ve tried several ways like
UWorld* const World = GWorld;
UStaticMeshComponent* meshComponent = World->SpawnActor<UStaticMeshComponent>(UStaticMeshComponent::StaticClass());
meshComponent->SetStaticMesh(((UStaticMesh*)(ImportedObjects[0])));
or
USceneComponent* scnComponent = ConstructObject<USceneComponent>(USceneComponent::StaticClass(), ImportedObjects[0], _T("scnteterita"));
if (scnComponent)
{
scnComponent->RegisterComponent();
scnComponent->AttachTo(GetRootComponent(), NAME_None);
}
But I only manage to get crashes.
Thank you in advance regards F.