mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27: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
|
||||
|
||||
const PRESET_NAMES = [ "Skip", "Import with Material Maker" ]
|
||||
const PRESET_OPTIONS = [
|
||||
[{ name="skip", default_value=true }],
|
||||
[{ name="skip", default_value=false }]
|
||||
]
|
||||
|
||||
func _init(p):
|
||||
plugin = p
|
||||
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func get_import_options(preset : int):
|
||||
return []
|
||||
return PRESET_OPTIONS[preset]
|
||||
|
||||
func get_import_order():
|
||||
return 1
|
||||
|
||||
func get_importer_name():
|
||||
return "MaterialMakerImporter"
|
||||
return "material_maker.import"
|
||||
|
||||
func get_option_visibility(option: String, options: Dictionary):
|
||||
return false
|
||||
return true
|
||||
|
||||
func get_preset_count():
|
||||
return 1
|
||||
return 2
|
||||
|
||||
func get_preset_name(preset: int) -> String:
|
||||
return "Default"
|
||||
return PRESET_NAMES[preset]
|
||||
|
||||
func get_priority():
|
||||
return 1
|
||||
return 0.1
|
||||
|
||||
func get_recognized_extensions():
|
||||
return [ "ptex" ]
|
||||
@ -43,10 +46,11 @@ 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:
|
||||
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)
|
||||
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)
|
||||
return OK
|
||||
|
@ -16,6 +16,13 @@ func register_material_maker_import(__):
|
||||
importer = preload("res://addons/material_maker/import_plugin/ptex_import.gd").new(self)
|
||||
add_import_plugin(importer)
|
||||
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():
|
||||
remove_tool_menu_item("Material Maker")
|
||||
|
Loading…
Reference in New Issue
Block a user