0 votes

This is supposed to allow me to import .yarn.txt files, but the engine doesn't notice them. I do have the plugin enabled.


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()


func _exit_tree():

    yarn_file_importer = null


extends Resource

class_name YarnFile, "res://addons/gdyarn/YarnSpinnerLogo.png"

var text = ""


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()
    return ResourceSaver.save("%s.%s" % [save_path, get_save_extension()], yarnfile)
in Engine by (55 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.