From 2bbedd35ddfa0eb4872003383c5ea91b887427ac Mon Sep 17 00:00:00 2001 From: Geequlim Date: Tue, 31 May 2016 15:06:24 +0800 Subject: [PATCH] Expose ResourceImportMetadata::set_source_md5 for script --- core/resource.cpp | 1 + demos/plugins/custom_import_plugin/import_plugin.gd | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/resource.cpp b/core/resource.cpp index b7a5bad4b86..97dee3e1d70 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -133,6 +133,7 @@ void ResourceImportMetadata::_bind_methods() { ObjectTypeDB::bind_method(_MD("add_source","path","md5"),&ResourceImportMetadata::add_source, ""); ObjectTypeDB::bind_method(_MD("get_source_path","idx"),&ResourceImportMetadata::get_source_path); ObjectTypeDB::bind_method(_MD("get_source_md5","idx"),&ResourceImportMetadata::get_source_md5); + ObjectTypeDB::bind_method(_MD("set_source_md5","idx", "md5"),&ResourceImportMetadata::set_source_md5); ObjectTypeDB::bind_method(_MD("remove_source","idx"),&ResourceImportMetadata::remove_source); ObjectTypeDB::bind_method(_MD("get_source_count"),&ResourceImportMetadata::get_source_count); ObjectTypeDB::bind_method(_MD("set_option","key","value"),&ResourceImportMetadata::set_option); diff --git a/demos/plugins/custom_import_plugin/import_plugin.gd b/demos/plugins/custom_import_plugin/import_plugin.gd index 2cf8a0302f0..99f0289e511 100644 --- a/demos/plugins/custom_import_plugin/import_plugin.gd +++ b/demos/plugins/custom_import_plugin/import_plugin.gd @@ -56,17 +56,21 @@ func import(path,metadata): if (use_red_anyway): color=Color8(255,0,0) - - material.set_parameter(FixedMaterial.PARAM_DIFFUSE,color) + + material.set_parameter(FixedMaterial.PARAM_DIFFUSE,color) # Make sure import metadata links to this plugin - + metadata.set_editor("silly_material") + # Update the md5 value of the source file + + metadata.set_source_md5(0, f.get_md5(source)) + # Update the import metadata material.set_import_metadata(metadata) - + # Save err = ResourceSaver.save(path,material) @@ -78,4 +82,3 @@ func config(base_control): dialog = preload("res://addons/custom_import_plugin/material_dialog.tscn").instance() base_control.add_child(dialog) -