mirror of
https://github.com/Relintai/material-maker.git
synced 2025-01-25 18:59:18 +01:00
Updated the plugin with an option to register/unregister the importer, and added an option to skip .ptex imports.
This commit is contained in:
parent
1186cd44ca
commit
b7a54b3242
@ -3,32 +3,35 @@ extends EditorImportPlugin
|
|||||||
|
|
||||||
var plugin = null
|
var plugin = null
|
||||||
|
|
||||||
|
const PRESET_NAMES = [ "Skip", "Import with Material Maker" ]
|
||||||
|
const PRESET_OPTIONS = [
|
||||||
|
[{ name="skip", default_value=true }],
|
||||||
|
[{ name="skip", default_value=false }]
|
||||||
|
]
|
||||||
|
|
||||||
func _init(p):
|
func _init(p):
|
||||||
plugin = p
|
plugin = p
|
||||||
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
func get_import_options(preset : int):
|
func get_import_options(preset : int):
|
||||||
return []
|
return PRESET_OPTIONS[preset]
|
||||||
|
|
||||||
func get_import_order():
|
func get_import_order():
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
func get_importer_name():
|
func get_importer_name():
|
||||||
return "MaterialMakerImporter"
|
return "material_maker.import"
|
||||||
|
|
||||||
func get_option_visibility(option: String, options: Dictionary):
|
func get_option_visibility(option: String, options: Dictionary):
|
||||||
return false
|
return true
|
||||||
|
|
||||||
func get_preset_count():
|
func get_preset_count():
|
||||||
return 1
|
return 2
|
||||||
|
|
||||||
func get_preset_name(preset: int) -> String:
|
func get_preset_name(preset: int) -> String:
|
||||||
return "Default"
|
return PRESET_NAMES[preset]
|
||||||
|
|
||||||
func get_priority():
|
func get_priority():
|
||||||
return 1
|
return 0.1
|
||||||
|
|
||||||
func get_recognized_extensions():
|
func get_recognized_extensions():
|
||||||
return [ "ptex" ]
|
return [ "ptex" ]
|
||||||
@ -43,10 +46,11 @@ func get_visible_name():
|
|||||||
return "Material Maker Importer"
|
return "Material Maker Importer"
|
||||||
|
|
||||||
func import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> int:
|
func import(source_file: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> int:
|
||||||
var filename = save_path + "." + get_save_extension()
|
if !options.skip:
|
||||||
var material = plugin.generate_material(source_file)
|
var filename = save_path + "." + get_save_extension()
|
||||||
while material is GDScriptFunctionState:
|
var material = plugin.generate_material(source_file)
|
||||||
material = yield(material, "completed")
|
while material is GDScriptFunctionState:
|
||||||
if material != null:
|
material = yield(material, "completed")
|
||||||
ResourceSaver.save(filename, material)
|
if material != null:
|
||||||
|
ResourceSaver.save(filename, material)
|
||||||
return OK
|
return OK
|
||||||
|
@ -16,6 +16,13 @@ func register_material_maker_import(__):
|
|||||||
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
||||||
add_import_plugin(importer)
|
add_import_plugin(importer)
|
||||||
remove_tool_menu_item("Register Material Maker Import")
|
remove_tool_menu_item("Register Material Maker Import")
|
||||||
|
add_tool_menu_item("Unregister Material Maker Import", self, "unregister_material_maker_import")
|
||||||
|
|
||||||
|
func unregister_material_maker_import(__):
|
||||||
|
remove_import_plugin(importer)
|
||||||
|
importer = null
|
||||||
|
remove_tool_menu_item("Unregister Material Maker Import")
|
||||||
|
add_tool_menu_item("Register Material Maker Import", self, "register_material_maker_import")
|
||||||
|
|
||||||
func _exit_tree():
|
func _exit_tree():
|
||||||
remove_tool_menu_item("Material Maker")
|
remove_tool_menu_item("Material Maker")
|
||||||
|
Loading…
Reference in New Issue
Block a user