EditorImportPlugin for custom fbx import

Godot Version

4.3-stable

Question

Hey
Im trying to implement custom FBX scene import using EditorImportPlugin class.

I successfully created baseic plugin and initiated import plugin with

add_import_plugin(my_importer_plugin, true)

here is some parts of my fbx scene importer code:

func _get_recognized_extensions() -> PackedStringArray:
	return PackedStringArray(["fbx", "Fbx", "FBX"])

func _get_resource_type():
	return "PackedScene";

func _get_save_extension():
	return "scn"

func _import(source_file, save_path, options, r_platform_variants, r_gen_files):
	var base_dir = source_file.get_base_dir();
	var material_assigner_extension = extension.new();
	
	var fbx = FBXDocument.new();
	
	fbx.register_gltf_document_extension(material_assigner_extension)

	var state = FBXState.new();
	
	var path = ProjectSettings.globalize_path(source_file)
	
	state.set_bake_fps(60);

	
	var status = fbx.append_from_file(path, state, 0, base_dir);
	
	if status != OK:
		fbx.unregister_gltf_document_extension(material_assigner_extension)
	
	state.json = get_json(base_dir, state.filename)
	
	
	var scene = fbx.generate_scene(state, state.get_bake_fps(), false, false);
	
	
	process_materials(state, base_dir, state.filename);

	fbx.write_to_filesystem(scene, save_path)

and here is my extension:


extends GLTFDocumentExtension


func _import_post(gstate: GLTFState, node: Node) -> Error:
	print_rich("POST")
	return OK
	pass

func _import_preflight(state: GLTFState, extensions: PackedStringArray) -> Error:
	print_rich("CyKA ZAEBALO")
	
	return OK

The first issue is:
I am no getting any print messages from the extension.

Second issue is:
It looks like the main (embeded) fbx importer initializes no matter what and only after my _import method goes…

Here is my import dock component im getting when picking my custom import schema

The real question is:
How can I manipulate the fbx import process? Especially the material assignment and texture lookup?

Please help. Thanks.

PS:
The current process_materials method changes automatically created StandardMaterial3D to a custom ShaderMaterial., it does change it, but in the resulting scene I get the StandardMaterial3D again, so I dont understand either smth overrides the materials again or my fbx.write_to_filesystem simply doesnt work

Ok, the first thing I found is that you cannot use GLTFDocumentExtension class to extend your FBX import (it works only with GLTFDocument). Its hillarious cuz there is no such Extension for FBX import and even FBXDocument is inherited from GLTFDocument.
@fire, if you have some time please explain how that supposed to work? (Import extension for fbx import)

Theres an open pull request to fix this. Got delayed :frowning:

This one?