diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index 14a92cc15..d6d7a3aa7 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -539,6 +539,7 @@ + Emitted when the given [code]resource[/code] was saved on disc. See also [signal scene_saved], which is used for edited scenes instead of this signal. The [PackedScene] does not count as a saved resource. @@ -550,7 +551,13 @@ - Emitted when user closes a scene. The argument is file path to a closed scene. + Emitted when user closes a scene. The argument is a file path to the closed scene. + + + + + + Emitted when a scene was saved on disc. The argument is a file path to the saved scene. See also [signal resource_saved], used for other resources. diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp index a474a6433..e63292d51 100644 --- a/editor/editor_data.cpp +++ b/editor/editor_data.cpp @@ -390,6 +390,12 @@ void EditorData::notify_resource_saved(const Ref &p_resource) { } } +void EditorData::notify_scene_saved(const String &p_path) { + for (int i = 0; i < editor_plugins.size(); i++) { + editor_plugins[i]->notify_scene_saved(p_path); + } +} + void EditorData::clear_editor_states() { for (int i = 0; i < editor_plugins.size(); i++) { editor_plugins[i]->clear(); diff --git a/editor/editor_data.h b/editor/editor_data.h index 13d3b7b67..df3c550c1 100644 --- a/editor/editor_data.h +++ b/editor/editor_data.h @@ -242,6 +242,7 @@ public: Dictionary restore_edited_scene_state(EditorSelection *p_selection, EditorHistory *p_history); void notify_edited_scene_changed(); void notify_resource_saved(const Ref &p_resource); + void notify_scene_saved(const String &p_path); bool class_equals_or_inherits(const StringName &p_class, const StringName &p_inherits) const; bool script_class_is_parent(const StringName &p_class, const StringName &p_inherits) const; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 0ac2f4ad7..321da0061 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1670,6 +1670,7 @@ void EditorNode::_save_scene(String p_file, int idx) { // This needs to be emitted before saving external resources. emit_signal("scene_saved", p_file); + editor_data.notify_scene_saved(p_file); _save_external_resources(); editor_data.save_editor_external_data(); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index a400026b7..e9ed96c79 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -626,6 +626,10 @@ void EditorPlugin::notify_resource_saved(const Ref &p_resource) { emit_signal("resource_saved", p_resource); } +void EditorPlugin::notify_scene_saved(const String &p_scene_filepath) { + emit_signal("scene_saved", p_scene_filepath); +} + bool EditorPlugin::forward_canvas_gui_input(const Ref &p_event) { if (get_script_instance() && get_script_instance()->has_method("forward_canvas_gui_input")) { return get_script_instance()->call("forward_canvas_gui_input", p_event); @@ -971,6 +975,7 @@ void EditorPlugin::_bind_methods() { ADD_SIGNAL(MethodInfo("scene_closed", PropertyInfo(Variant::STRING, "filepath"))); ADD_SIGNAL(MethodInfo("main_screen_changed", PropertyInfo(Variant::STRING, "screen_name"))); ADD_SIGNAL(MethodInfo("resource_saved", PropertyInfo(Variant::OBJECT, "resource", PROPERTY_HINT_RESOURCE_TYPE, "Resource"))); + ADD_SIGNAL(MethodInfo("scene_saved", PropertyInfo(Variant::STRING, "filepath"))); BIND_ENUM_CONSTANT(CONTAINER_TOOLBAR); BIND_ENUM_CONSTANT(CONTAINER_SPATIAL_EDITOR_MENU); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index cb17f8be3..813cdf065 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -234,6 +234,7 @@ public: void notify_scene_changed(const Node *scn_root); void notify_scene_closed(const String &scene_filepath); void notify_resource_saved(const Ref &p_resource); + void notify_scene_saved(const String &p_scene_filepath); virtual bool forward_canvas_gui_input(const Ref &p_event); virtual void forward_canvas_draw_over_viewport(Control *p_overlay);