0

I am trying to create an EditorPlugin/EditorImportPlugin to import fbx files. More specifically I want to extract the animations from the files and save them as a .res file. Normally I go over the advanced import tab select the animation and enable save to file: enter image description here

I have my EditorPlugin:

[Tool]
public partial class FbxAnimationImportPlugin : EditorPlugin
{
 private FbxAnimationImporter fbxAnimationImporter;
 public override void _EnterTree()
 {
 fbxAnimationImporter = new FbxAnimationImporter();
 AddImportPlugin(fbxAnimationImporter);
 }
 public override void _ExitTree()
 {
 RemoveImportPlugin(fbxAnimationImporter);
 fbxAnimationImporter = null;
 }
}

And the corresponding EditorImportPlugin:

[Tool]
public partial class FbxAnimationImporter : EditorImportPlugin
{
 public override string _GetImporterName()
 {
 return "fbx_animation_importer";
 }
 public override string _GetVisibleName()
 {
 return "FbxAnimationImporter";
 }
 public override string[] _GetRecognizedExtensions()
 {
 return ["fbx"];
 }
 public override string _GetSaveExtension()
 {
 return "res";
 }
 public override string _GetResourceType()
 {
 return "PackedScene";
 }
 public override Error _Import(string sourceFile, string savePath, Dictionary options, Array<string> platformVariants, Array<string> genFiles)
 {
 Resource scene = ResourceLoader.Load(sourceFile, "PackedScene");
 //Doing stuff with the scene and animations...
 return Error.Ok;
 }
}

However I get the error:

ERROR: Failed loading resource: res://assets/protof/[email protected]. Make sure resources have been imported by opening the project in the editor at least once.

How can I load the fbx file into a PackedScene so I can access the embedded AnimationPlayer?

asked Sep 12, 2025 at 18:55

1 Answer 1

0

I solved my Problem using an EditorScenePostImportPlugin

[Tool]
public partial class FbxAnimationImporter : EditorScenePostImportPlugin
{
 public override void _PostProcess(Node scene)
 {
 if ((bool)GetOptionValue("Save Animation to .res"))
 {
 AnimationPlayer animationPlayer = scene.GetNodeOrNull<AnimationPlayer>("AnimationPlayer");
 if (animationPlayer != null)
 {
 string sourcePath = (string)GetOptionValue("file_path_hack");
 foreach (string animationName in animationPlayer.GetAnimationList())
 {
 Animation animation = animationPlayer.GetAnimation(animationName);
 string saveFile = sourcePath + "_" + animationName + ".res";
 ResourceSaver.Save(animation, saveFile);
 }
 }
 else
 {
 GD.PushError("FBX/Scene has NO Animation(Player)");
 }
 }
 }
 public override void _GetImportOptions(string path)
 {
 AddImportOption("Save Animation to .res", false);
 AddImportOption("file_path_hack", path);
 }
 public override Variant _GetOptionVisibility(string path, bool forAnimation, string option)
 {
 if (option.Equals("file_path_hack")) return false;
 return base._GetOptionVisibility(path, forAnimation, option);
 }
 
}
answered Sep 13, 2025 at 10:06
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.