Download

Loading FBX files (and placing) inside a editor plugin

I think it could sound like a no-sense question since you can already import it from inside the editor itself, but I wanna to load a proper fileformat that contains somekind of scene definition and I managed already to load a texture into the editor, but I cannot figure yet how to load a .fbx file.

Also somebody could say that this question has been answered lots of times, but the questions are usually related to load fbx during runtime of the app not into the editor.

I know that if I use


UStaticMesh* UnrealMesh = NewObject<UStaticMesh>(Package, FName(_T("MY CREATED Mesh")), RF_Public);

I can add a void mesh to my editor resources, but how can I load a fbx file there?

Btw is there any chance to add a instance of that UStaticMesh to my current scene?

Thank you in advance, F.

I’ll make a partial reply for my own question, how to load an fbx:


if (FModuleManager::Get().IsModuleLoaded("AssetTools"))
{
	TArray<FString> files;
	files.Add(TEXT("D:\\mybox001.fbx"));

	FString packagePath = TEXT("/Game/mytest");
	FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked<FAssetToolsModule>("AssetTools");
	TArray<UObject*>  ImportedObjects = AssetToolsModule.Get().ImportAssets(files, packagePath);
}

Someone knows how can I place it into the scene?

Regards, F.

More on this I’ve tried


USceneComponent* scnComponent = ConstructObject<USceneComponent>(USceneComponent::StaticClass(), ImportedObjects[0], _T("scnmybox"));
if (scnComponent)
{
	scnComponent->RegisterComponent();
}

But I only manage to get a crash :S