summaryrefslogtreecommitdiffstats
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.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 907bc81674..49459a0ba0 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -267,18 +267,26 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
case FILE_SAVE: {
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
+ TextShaderEditor *editor = edited_shaders[index].shader_editor;
+ if (editor && editor->get_trim_trailing_whitespace_on_save()) {
+ editor->trim_trailing_whitespace();
+ }
if (edited_shaders[index].shader.is_valid()) {
EditorNode::get_singleton()->save_resource(edited_shaders[index].shader);
} else {
EditorNode::get_singleton()->save_resource(edited_shaders[index].shader_inc);
}
- if (edited_shaders[index].shader_editor) {
- edited_shaders[index].shader_editor->tag_saved_version();
+ if (editor) {
+ editor->tag_saved_version();
}
} break;
case FILE_SAVE_AS: {
int index = shader_tabs->get_current_tab();
ERR_FAIL_INDEX(index, shader_tabs->get_tab_count());
+ TextShaderEditor *editor = edited_shaders[index].shader_editor;
+ if (editor && editor->get_trim_trailing_whitespace_on_save()) {
+ editor->trim_trailing_whitespace();
+ }
String path;
if (edited_shaders[index].shader.is_valid()) {
path = edited_shaders[index].shader->get_path();
@@ -293,8 +301,8 @@ void ShaderEditorPlugin::_menu_item_pressed(int p_index) {
}
EditorNode::get_singleton()->save_resource_as(edited_shaders[index].shader_inc, path);
}
- if (edited_shaders[index].shader_editor) {
- edited_shaders[index].shader_editor->tag_saved_version();
+ if (editor) {
+ editor->tag_saved_version();
}
} break;
case FILE_INSPECT: {
@@ -376,6 +384,12 @@ bool ShaderEditorPlugin::can_drop_data_fw(const Point2 &p_point, const Variant &
return true;
}
}
+ if (ResourceLoader::exists(file, "ShaderInclude")) {
+ Ref<ShaderInclude> sinclude = ResourceLoader::load(file);
+ if (sinclude.is_valid()) {
+ return true;
+ }
+ }
}
return false;
}
@@ -405,11 +419,10 @@ void ShaderEditorPlugin::drop_data_fw(const Point2 &p_point, const Variant &p_da
for (int i = 0; i < files.size(); i++) {
String file = files[i];
- if (!ResourceLoader::exists(file, "Shader")) {
- continue;
+ Ref<Resource> res;
+ if (ResourceLoader::exists(file, "Shader") || ResourceLoader::exists(file, "ShaderInclude")) {
+ res = ResourceLoader::load(file);
}
-
- Ref<Resource> res = ResourceLoader::load(file);
if (res.is_valid()) {
edit(res.ptr());
}