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-10-20 16:22:06 +02:00
|
|
|
func _init(p) -> void:
|
2019-07-31 20:53:00 +02:00
|
|
|
plugin = p
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_import_options(preset : int) -> Array:
|
2019-10-18 07:22:40 +02:00
|
|
|
return PRESET_OPTIONS[preset]
|
2019-07-31 20:53:00 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_import_order() -> int:
|
2019-07-31 20:53:00 +02:00
|
|
|
return 1
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_importer_name() -> String:
|
2019-10-18 07:22:40 +02:00
|
|
|
return "material_maker.import"
|
2019-07-31 20:53:00 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_option_visibility(option: String, options: Dictionary) -> bool:
|
2019-10-18 07:22:40 +02:00
|
|
|
return true
|
2019-07-31 20:53:00 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_preset_count() -> int:
|
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
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_priority() -> float:
|
2019-10-18 07:22:40 +02:00
|
|
|
return 0.1
|
2019-07-31 20:53:00 +02:00
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_recognized_extensions() -> Array:
|
2019-07-31 20:53:00 +02:00
|
|
|
return [ "ptex" ]
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_resource_type() -> String:
|
2019-07-31 20:53:00 +02:00
|
|
|
return "Material"
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_save_extension() -> String:
|
2019-07-31 20:53:00 +02:00
|
|
|
return "tres"
|
|
|
|
|
2019-10-20 16:22:06 +02:00
|
|
|
func get_visible_name() -> String:
|
2019-07-31 20:53:00 +02:00
|
|
|
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
|