2019-10-01 23:15:36 +02:00
|
|
|
tool
|
2019-07-31 20:53:00 +02:00
|
|
|
extends EditorImportPlugin
|
|
|
|
|
|
|
|
var plugin = null
|
|
|
|
|
2019-10-18 07:22:40 +02:00
|
|
|
const PRESET_NAMES = [ "Skip", "Import with Material Maker" ]
|
|
|
|
const PRESET_OPTIONS = [
|
|
|
|
[{ name="skip", default_value=true }],
|
|
|
|
[{ name="skip", default_value=false }]
|
|
|
|
]
|
|
|
|
|
2019-07-31 20:53:00 +02:00
|
|
|
func _init(p):
|
|
|
|
plugin = p
|
|
|
|
|
|
|
|
func get_import_options(preset : int):
|
2019-10-18 07:22:40 +02:00
|
|
|
return PRESET_OPTIONS[preset]
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_import_order():
|
|
|
|
return 1
|
|
|
|
|
|
|
|
func get_importer_name():
|
2019-10-18 07:22:40 +02:00
|
|
|
return "material_maker.import"
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_option_visibility(option: String, options: Dictionary):
|
2019-10-18 07:22:40 +02:00
|
|
|
return true
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_preset_count():
|
2019-10-18 07:22:40 +02:00
|
|
|
return 2
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_preset_name(preset: int) -> String:
|
2019-10-18 07:22:40 +02:00
|
|
|
return PRESET_NAMES[preset]
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_priority():
|
2019-10-18 07:22:40 +02:00
|
|
|
return 0.1
|
2019-07-31 20:53:00 +02:00
|
|
|
|
|
|
|
func get_recognized_extensions():
|
|
|
|
return [ "ptex" ]
|
|
|
|
|
|
|
|
func get_resource_type():
|
|
|
|
return "Material"
|
|
|
|
|
|
|
|
func get_save_extension():
|
|
|
|
return "tres"
|
|
|
|
|
|
|
|
func get_visible_name():
|
|
|
|
return "Material Maker Importer"
|
|
|
|
|
|
|
|
func import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> int:
|
2019-10-18 07:22:40 +02:00
|
|
|
if !options.skip:
|
|
|
|
var filename = save_path + "." + get_save_extension()
|
|
|
|
var material = plugin.generate_material(source_file)
|
|
|
|
while material is GDScriptFunctionState:
|
|
|
|
material = yield(material, "completed")
|
|
|
|
if material != null:
|
|
|
|
ResourceSaver.save(filename, material)
|
2019-07-31 20:53:00 +02:00
|
|
|
return OK
|