Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Noah Burck |
This is supposed to allow me to import .yarn.txt files, but the engine doesn’t notice them. I do have the plugin enabled.
res://addons/gdyarn/yarn_init.gd
tool
extends EditorPlugin
var yarn_file_importer
func _enter_tree():
add_custom_type("YarnFile", "Resource", preload("YarnFile.gd"), preload("res://addons/gdyarn/YarnSpinnerLogo.png"))
yarn_file_importer = preload("yarn_file_importer.gd").new()
add_import_plugin(yarn_file_importer)
func _exit_tree():
remove_import_plugin(yarn_file_importer)
remove_custom_type("YarnFile")
yarn_file_importer = null
res://addons/gdyarn/YarnFile.gd
extends Resource
class_name YarnFile, "res://addons/gdyarn/YarnSpinnerLogo.png"
var text = ""
res://addons/gdyarn/yarn_file_importer.gd
tool
extends EditorImportPlugin
func get_importer_name():
return "yarnfile"
func get_visible_name():
return "Yarn File"
func get_recognized_extensions():
return ["yarn.txt"]
func get_save_extension():
return "res"
func get_resource_type():
return "YarnFile"
func get_import_options(preset):
return []
func import(source_file, save_path, options, r_platform_variants, r_gen_files):
var f = File.new()
var err = f.open(source_file, File.READ)
if err != OK:
return err
var yarnfile = YarnFile.new()
yarnfile.text = f.get_as_text()
f.close()
return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], yarnfile)