diff options
author | Zher Huei Lee <lee.zh.92@gmail.com> | 2017-06-11 17:18:22 +0800 |
---|---|---|
committer | Zher Huei Lee <lee.zh.92@gmail.com> | 2017-06-11 17:18:22 +0800 |
commit | 9ecdf522bd95a3318ac75ff8f9e237b35b5beca3 (patch) | |
tree | efc49bd1d14994b03ad9dfea431fc11f2a18d7fb | |
parent | bcc435094d0734174818cf3e55887a26ef111686 (diff) |
Added EditorPlugin.remove_import_plugin()
Allows addons with import extensions to clean up properly on
removal.
-rw-r--r-- | core/io/resource_import.h | 1 | ||||
-rw-r--r-- | editor/editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/editor_plugin.h | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/core/io/resource_import.h b/core/io/resource_import.h index 25b7a534b2..9d2a5180dc 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -61,6 +61,7 @@ public: String get_internal_resource_path(const String &p_path) const; void add_importer(const Ref<ResourceImporter> &p_importer) { importers.insert(p_importer); } + void remove_importer(const Ref<ResourceImporter> &p_importer) { importers.erase(p_importer); } Ref<ResourceImporter> get_importer_by_name(const String &p_name); Ref<ResourceImporter> get_importer_by_extension(const String &p_extension); void get_importers_for_extension(const String &p_extension, List<Ref<ResourceImporter> > *r_importers); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index 1b8d1b1677..6fcea98e32 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -281,6 +281,11 @@ void EditorPlugin::add_import_plugin(const Ref<EditorImportPlugin> &p_importer) EditorFileSystem::get_singleton()->scan_changes(); } +void EditorPlugin::remove_import_plugin(const Ref<EditorImportPlugin> &p_importer) { + ResourceFormatImporter::get_singleton()->remove_importer(p_importer); + EditorFileSystem::get_singleton()->scan_changes(); +} + void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { @@ -366,6 +371,7 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); ClassDB::bind_method(D_METHOD("edit_resource"), &EditorPlugin::edit_resource); ClassDB::bind_method(D_METHOD("add_import_plugin"), &EditorPlugin::add_import_plugin); + ClassDB::bind_method(D_METHOD("remove_import_plugin"), &EditorPlugin::remove_import_plugin); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_canvas_gui_input", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("forward_draw_over_canvas", PropertyInfo(Variant::TRANSFORM2D, "canvas_xform"), PropertyInfo(Variant::OBJECT, "canvas:Control"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "forward_spatial_gui_input", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"), PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 1ef447a6b8..c607846ec9 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -148,6 +148,7 @@ public: virtual void save_global_state(); void add_import_plugin(const Ref<EditorImportPlugin> &p_importer); + void remove_import_plugin(const Ref<EditorImportPlugin> &p_importer); EditorPlugin(); virtual ~EditorPlugin(); |