summaryrefslogtreecommitdiff
path: root/editor/plugins/shader_editor_plugin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins/shader_editor_plugin.cpp')
-rw-r--r--editor/plugins/shader_editor_plugin.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 7861c8d354..6bc0f1580d 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -236,6 +236,26 @@ void ShaderEditorPlugin::_close_shader(int p_index) {
EditorUndoRedoManager::get_singleton()->clear_history(); // To prevent undo on deleted graphs.
}
+void ShaderEditorPlugin::_close_builtin_shaders_from_scene(const String &p_scene) {
+ for (uint32_t i = 0; i < edited_shaders.size();) {
+ Ref<Shader> &shader = edited_shaders[i].shader;
+ if (shader.is_valid()) {
+ if (shader->is_built_in() && shader->get_path().begins_with(p_scene)) {
+ _close_shader(i);
+ continue;
+ }
+ }
+ Ref<ShaderInclude> &include = edited_shaders[i].shader_inc;
+ if (include.is_valid()) {
+ if (include->is_built_in() && include->get_path().begins_with(p_scene)) {
+ _close_shader(i);
+ continue;
+ }
+ }
+ i++;
+ }
+}
+
void ShaderEditorPlugin::_resource_saved(Object *obj) {
// May have been renamed on save.
for (EditedShader &edited_shader : edited_shaders) {
@@ -422,6 +442,14 @@ void ShaderEditorPlugin::drop_data_fw(const Point2 &p_point, const Variant &p_da
}
}
+void ShaderEditorPlugin::_notification(int p_what) {
+ switch (p_what) {
+ case NOTIFICATION_READY: {
+ EditorNode::get_singleton()->connect("scene_closed", callable_mp(this, &ShaderEditorPlugin::_close_builtin_shaders_from_scene));
+ } break;
+ }
+}
+
ShaderEditorPlugin::ShaderEditorPlugin() {
main_split = memnew(HSplitContainer);