Godot Version
4.4
Question
I am trying to add importing of a filetype to my plugin but even after following the tutorial and looking around, I have ended up with the error
Error importing 'res://SavedDialogueScenes/TestExport.ds'.
I think everything else in the script file is correct but I am completely unsure and have no possible idea for why this may be happening .
Plugin File
@tool
extends EditorPlugin
var editor = preload("res://addons/DialogueSystem/DialogueEditor/DialogueEditor.tscn").instantiate()
var dialoguesceneimporter = preload("res://addons/DialogueSystem/DialogueEditor/DialogueSceneImporter.gd").new()
func _enter_tree() -> void:
# Initialization of the plugin goes here.
add_control_to_dock(EditorPlugin.DOCK_SLOT_RIGHT_BL,editor)
add_custom_type("DialogueScene","Resource",preload("res://addons/DialogueSystem/DialogueEditor/DialogueScene.gd"),preload("res://addons/DialogueSystem/DialogueSystemNode/DialogueIcon.jpg"))
add_custom_type("DialogueSystem","Node",preload("res://addons/DialogueSystem/DialogueSystemNode/DialogueSystemNode.gd"),preload("res://addons/DialogueSystem/DialogueSystemNode/DialogueIcon.jpg"))
add_import_plugin(dialoguesceneimporter)
func _exit_tree() -> void:
# Clean-up of the plugin goes here.
remove_control_from_docks(editor)
remove_custom_type("DialogueScene")
remove_custom_type("DialogueSystem")
remove_import_plugin(dialoguesceneimporter)
DialogueSceneImporter.gd
@tool
extends EditorImportPlugin
func _get_priority() -> float:
return 2.0
func _get_importer_name() -> String:
return "H58h44.DialogueScene"
func _get_visible_name() -> String:
return "Dialogue Scene"
func _get_recognized_extensions() -> PackedStringArray:
return ["ds"]
func _get_save_extension() -> String:
return "dialogue"
func _get_import_options(path: String, preset_index: int) -> Array[Dictionary]:
return [ ]
func _get_resource_type() -> String:
return "DialogueScene"
func get_preset_count():
return 1
func get_preset_name(preset):
return "Default"
func get_import_options(preset):
return [ ]
func get_option_visibility(option, options):
return true
func _import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array[String], gen_files: Array[String]):
var file = FileAccess.open(source_file,FileAccess.READ)
if file == null:
return FileAccess.get_open_error()
var data = JSON.parse_string(file.get_as_text())
var material : DialogueScene = DialogueScene.new()
material.Branches = data["Branches"]
material.Flags = data["Flags"]
material.Characters = data["Characters"]
return ResourceSaver.save(material,str(save_path,".",_get_save_extension()))