I want to import fbx in C++ and meet the same problem. And here is how I fix it. ( There should be better ways to solve the problem but these codes works for me)
Step 1: Create level sequence asset
just search for code here: FVREditorActionCallbacks::CreateNewSequence
in VREditorActions.cpp.
Step 2: Get sequncer
you need to include LevelSequenceEditor plugin to get ISequencer.
link text
my build.cs like this:
PublicIncludePaths.AddRange(
new string[] {
"LevelSequenceEditor/Private",
"LevelSequenceEditor/Classes"
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"LevelSequence"
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"MovieSceneTools",
"LevelSequenceEditor",
"Sequencer",
"SequencerWidgets"
}
);
and in my .uplugin:
"Plugins": [
{
"Name": "LevelSequenceEditor",
"Enabled": true
}
]
and if all modules are included, type these codes:
UAssetEditorSubsystem* AssetEditorSubsystem = GEditor->GetEditorSubsystem<UAssetEditorSubsystem>(); // get sequence editor
AssetEditorSubsystem->OpenEditorForAsset(YourLevelSeuquenceAsset);
auto Editor = AssetEditorSubsystem->FindEditorForAsset(YourLevelSequenceAsset, false);
FLevelSequenceEditorToolkit* LevelSequenceEditor = (FLevelSequenceEditorToolkit*)Editor;
ISequencer* Sequencer = LevelSequenceEditor->GetSequencer().Get(); // get sequencer
Step 3: Import FBX
if you want to import fbx with a dialog box, you can use “MovieSceneToolHelpers::ImportFBXWithDialog” like this:
UMovieScene* MovieScene = Sequencer->GetFocusedMovieSceneSequence()->GetMovieScene();
TMap<FGuid, FString> InObjectBindingMap;
MovieSceneToolHelpers::ImportFBXWithDialog(MovieScene, *Sequencer, InObjectBindingMap, TOptional<bool>());
else if you want it pure c++:
search OnImportFBXClicked()
in MovieSceneToolHelpers.cpp Get the codes you need and put them in a AsyncTask block:
AsyncTask(ENamedThreads::GameThread, [=]()
{
// your codes here
});