mirror of
https://github.com/godotengine/godot.git
synced 2024-11-23 04:33:29 +00:00
Merge pull request #83137 from jsjtxietian/close-shader-file-in-visual-editor-when-delete-file
Close shader in Shader Editor tab when deleting shader file in FileSystem panel
This commit is contained in:
commit
0258fa4db9
@ -64,6 +64,11 @@ void ShaderEditorPlugin::_update_shader_list() {
|
||||
}
|
||||
}
|
||||
|
||||
// When shader is deleted in filesystem dock, need this to correctly close shader editor.
|
||||
if (!path.is_empty()) {
|
||||
shader->set_meta("_edit_res_path", path);
|
||||
}
|
||||
|
||||
bool unsaved = false;
|
||||
if (edited_shader.shader_editor) {
|
||||
unsaved = edited_shader.shader_editor->is_unsaved();
|
||||
@ -571,10 +576,20 @@ void ShaderEditorPlugin::_window_changed(bool p_visible) {
|
||||
make_floating->set_visible(!p_visible);
|
||||
}
|
||||
|
||||
void ShaderEditorPlugin::_file_removed(const String &p_removed_file) {
|
||||
for (uint32_t i = 0; i < edited_shaders.size(); i++) {
|
||||
const Ref<Shader> &shader = edited_shaders[i].shader;
|
||||
if (shader->get_meta("_edit_res_path") == p_removed_file) {
|
||||
_close_shader(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
FileSystemDock::get_singleton()->connect("file_removed", callable_mp(this, &ShaderEditorPlugin::_file_removed));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
@ -87,6 +87,7 @@ class ShaderEditorPlugin : public EditorPlugin {
|
||||
void _resource_saved(Object *obj);
|
||||
void _close_shader(int p_index);
|
||||
void _close_builtin_shaders_from_scene(const String &p_scene);
|
||||
void _file_removed(const String &p_removed_file);
|
||||
|
||||
void _shader_created(Ref<Shader> p_shader);
|
||||
void _shader_include_created(Ref<ShaderInclude> p_shader_inc);
|
||||
|
Loading…
Reference in New Issue
Block a user