summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp22
-rw-r--r--editor/plugins/node_3d_editor_plugin.h9
-rw-r--r--editor/plugins/root_motion_editor_plugin.cpp2
-rw-r--r--editor/plugins/root_motion_editor_plugin.h2
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/shader_editor_plugin.cpp10
-rw-r--r--editor/plugins/shader_file_editor_plugin.cpp303
-rw-r--r--editor/plugins/shader_file_editor_plugin.h64
-rw-r--r--editor/plugins/style_box_editor_plugin.cpp2
-rw-r--r--editor/plugins/style_box_editor_plugin.h2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp11
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp10
-rw-r--r--editor/plugins/visual_shader_editor_plugin.h2
13 files changed, 422 insertions, 19 deletions
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 354c951a7c..f51b9b20e4 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -2287,9 +2287,27 @@ void Node3DEditorViewport::_update_freelook(real_t delta) {
return;
}
- const Vector3 forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
+ const FreelookNavigationScheme navigation_scheme = (FreelookNavigationScheme)EditorSettings::get_singleton()->get("editors/3d/freelook/freelook_navigation_scheme").operator int();
+
+ Vector3 forward;
+ if (navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
+ // Forward/backward keys will always go straight forward/backward, never moving on the Y axis.
+ forward = Vector3(0, 0, -1).rotated(Vector3(0, 1, 0), camera->get_rotation().y);
+ } else {
+ // Forward/backward keys will be relative to the camera pitch.
+ forward = camera->get_transform().basis.xform(Vector3(0, 0, -1));
+ }
+
const Vector3 right = camera->get_transform().basis.xform(Vector3(1, 0, 0));
- const Vector3 up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+
+ Vector3 up;
+ if (navigation_scheme == FREELOOK_PARTIALLY_AXIS_LOCKED || navigation_scheme == FREELOOK_FULLY_AXIS_LOCKED) {
+ // Up/down keys will always go up/down regardless of camera pitch.
+ up = Vector3(0, 1, 0);
+ } else {
+ // Up/down keys will be relative to the camera pitch.
+ up = camera->get_transform().basis.xform(Vector3(0, 1, 0));
+ }
Vector3 direction;
diff --git a/editor/plugins/node_3d_editor_plugin.h b/editor/plugins/node_3d_editor_plugin.h
index 2c3b15cfc8..71da14ae1a 100644
--- a/editor/plugins/node_3d_editor_plugin.h
+++ b/editor/plugins/node_3d_editor_plugin.h
@@ -241,6 +241,12 @@ public:
NAVIGATION_MODO,
};
+ enum FreelookNavigationScheme {
+ FREELOOK_DEFAULT,
+ FREELOOK_PARTIALLY_AXIS_LOCKED,
+ FREELOOK_FULLY_AXIS_LOCKED,
+ };
+
private:
float cpu_time_history[FRAME_TIME_HISTORY];
int cpu_time_history_index;
@@ -850,12 +856,11 @@ public:
static const int HIDDEN = 1;
static const int ON_TOP = 2;
-private:
+protected:
int current_state;
List<EditorNode3DGizmo *> current_gizmos;
HashMap<String, Vector<Ref<StandardMaterial3D>>> materials;
-protected:
static void _bind_methods();
virtual bool has_gizmo(Node3D *p_spatial);
virtual Ref<EditorNode3DGizmo> create_gizmo(Node3D *p_spatial);
diff --git a/editor/plugins/root_motion_editor_plugin.cpp b/editor/plugins/root_motion_editor_plugin.cpp
index 67e836082d..a7120c5d68 100644
--- a/editor/plugins/root_motion_editor_plugin.cpp
+++ b/editor/plugins/root_motion_editor_plugin.cpp
@@ -288,7 +288,7 @@ void EditorInspectorRootMotionPlugin::parse_begin(Object *p_object) {
//do none
}
-bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
+bool EditorInspectorRootMotionPlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
if (p_path == "root_motion_track" && p_object->is_class("AnimationTree") && p_type == Variant::NODE_PATH) {
EditorPropertyRootMotion *editor = memnew(EditorPropertyRootMotion);
diff --git a/editor/plugins/root_motion_editor_plugin.h b/editor/plugins/root_motion_editor_plugin.h
index 8a7691de5d..f72ad1ec05 100644
--- a/editor/plugins/root_motion_editor_plugin.h
+++ b/editor/plugins/root_motion_editor_plugin.h
@@ -65,7 +65,7 @@ class EditorInspectorRootMotionPlugin : public EditorInspectorPlugin {
public:
virtual bool can_handle(Object *p_object);
virtual void parse_begin(Object *p_object);
- virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
+ virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false);
virtual void parse_end();
};
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 4b8383e1e5..1a77eeb9de 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -172,7 +172,7 @@ void ScriptTextEditor::_update_member_keywords() {
for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) {
String name = E->get().name;
- if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP)
+ if (E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_SUBGROUP)
continue;
if (name.find("/") != -1)
continue;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 2a36700105..9ef8148241 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -193,6 +193,12 @@ void ShaderTextEditor::_check_shader_mode() {
}
}
+static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
+
+ RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
+ return RS::global_variable_type_get_shader_datatype(gvt);
+}
+
void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCodeCompletionOption> *r_options) {
_check_shader_mode();
@@ -200,7 +206,7 @@ void ShaderTextEditor::_code_complete_script(const String &p_code, List<ScriptCo
ShaderLanguage sl;
String calltip;
- sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), r_options, calltip);
+ sl.complete(p_code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type, r_options, calltip);
get_text_edit()->set_code_hint(calltip);
}
@@ -215,7 +221,7 @@ void ShaderTextEditor::_validate_script() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types());
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
if (err != OK) {
String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text();
diff --git a/editor/plugins/shader_file_editor_plugin.cpp b/editor/plugins/shader_file_editor_plugin.cpp
new file mode 100644
index 0000000000..296c7a01b6
--- /dev/null
+++ b/editor/plugins/shader_file_editor_plugin.cpp
@@ -0,0 +1,303 @@
+#include "shader_file_editor_plugin.h"
+
+#include "core/io/resource_loader.h"
+#include "core/io/resource_saver.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
+#include "editor/editor_node.h"
+#include "editor/editor_scale.h"
+#include "editor/editor_settings.h"
+#include "editor/property_editor.h"
+#include "servers/display_server.h"
+#include "servers/rendering/shader_types.h"
+
+/*** SHADER SCRIPT EDITOR ****/
+
+/*** SCRIPT EDITOR ******/
+
+void ShaderFileEditor::_update_version(const StringName &p_version_txt, const RD::ShaderStage p_stage) {
+}
+
+void ShaderFileEditor::_version_selected(int p_option) {
+
+ int c = versions->get_current();
+ StringName version_txt = versions->get_item_metadata(c);
+
+ RD::ShaderStage stage = RD::SHADER_STAGE_MAX;
+ int first_found = -1;
+
+ Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_txt);
+ ERR_FAIL_COND(bytecode.is_null());
+
+ for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
+ if (bytecode->get_stage_bytecode(RD::ShaderStage(i)).empty() && bytecode->get_stage_compile_error(RD::ShaderStage(i)) == String()) {
+ stages[i]->set_icon(Ref<Texture2D>());
+ continue;
+ }
+
+ Ref<Texture2D> icon;
+ if (bytecode->get_stage_compile_error(RD::ShaderStage(i)) != String()) {
+ icon = get_theme_icon("ImportFail", "EditorIcons");
+ } else {
+ icon = get_theme_icon("ImportCheck", "EditorIcons");
+ }
+ stages[i]->set_icon(icon);
+
+ if (first_found == -1) {
+ first_found = i;
+ }
+
+ if (stages[i]->is_pressed()) {
+ stage = RD::ShaderStage(i);
+ break;
+ }
+ }
+
+ error_text->clear();
+
+ if (stage == RD::SHADER_STAGE_MAX) { //need to change stage, does not have it
+ if (first_found == -1) {
+ error_text->add_text(TTR("No valid shader stages found."));
+ return; //well you did not put any stage I guess?
+ }
+ stages[first_found]->set_pressed(true);
+ stage = RD::ShaderStage(first_found);
+ }
+
+ String error = bytecode->get_stage_compile_error(stage);
+
+ error_text->push_font(get_theme_font("source", "EditorFonts"));
+
+ if (error == String()) {
+ error_text->add_text(TTR("Shader stage compiled without errors."));
+ } else {
+ error_text->add_text(error);
+ }
+}
+
+void ShaderFileEditor::_update_options() {
+
+ ERR_FAIL_COND(shader_file.is_null());
+
+ if (shader_file->get_base_error() != String()) {
+ stage_hb->hide();
+ versions->hide();
+ error_text->clear();
+ error_text->push_font(get_theme_font("source", "EditorFonts"));
+ error_text->add_text(vformat(TTR("File structure for '%s' contains unrecoverable errors:\n\n"), shader_file->get_path().get_file()));
+ error_text->add_text(shader_file->get_base_error());
+ return;
+ }
+
+ stage_hb->show();
+ versions->show();
+
+ int c = versions->get_current();
+ //remember current
+ versions->clear();
+ Vector<StringName> version_list = shader_file->get_version_list();
+
+ if (c >= version_list.size()) {
+ c = version_list.size() - 1;
+ }
+ if (c < 0) {
+ c = 0;
+ }
+
+ StringName current_version;
+
+ for (int i = 0; i < version_list.size(); i++) {
+ String title = version_list[i];
+ if (title == "") {
+ title = "default";
+ }
+
+ Ref<Texture2D> icon;
+
+ Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(version_list[i]);
+ ERR_FAIL_COND(bytecode.is_null());
+
+ bool failed = false;
+ for (int j = 0; j < RD::SHADER_STAGE_MAX; j++) {
+ String error = bytecode->get_stage_compile_error(RD::ShaderStage(j));
+ if (error != String()) {
+ failed = true;
+ }
+ }
+
+ if (failed) {
+ icon = get_theme_icon("ImportFail", "EditorIcons");
+ } else {
+ icon = get_theme_icon("ImportCheck", "EditorIcons");
+ }
+
+ versions->add_item(title, icon);
+ versions->set_item_metadata(i, version_list[i]);
+
+ if (i == c) {
+ versions->select(i);
+ current_version = version_list[i];
+ }
+ }
+
+ if (version_list.size() == 0) {
+ for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
+ stages[i]->set_disabled(true);
+ }
+ return;
+ }
+
+ Ref<RDShaderBytecode> bytecode = shader_file->get_bytecode(current_version);
+ ERR_FAIL_COND(bytecode.is_null());
+ int first_valid = -1;
+ int current = -1;
+ for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
+ Vector<uint8_t> bc = bytecode->get_stage_bytecode(RD::ShaderStage(i));
+ String error = bytecode->get_stage_compile_error(RD::ShaderStage(i));
+ bool disable = error == String() && bc.empty();
+ stages[i]->set_disabled(disable);
+ if (!disable) {
+ if (stages[i]->is_pressed()) {
+ current = i;
+ }
+ first_valid = i;
+ }
+ }
+
+ if (current == -1 && first_valid != -1) {
+ stages[first_valid]->set_pressed(true);
+ }
+
+ _version_selected(0);
+}
+
+void ShaderFileEditor::_notification(int p_what) {
+
+ if (p_what == NOTIFICATION_WM_FOCUS_IN) {
+ if (is_visible_in_tree() && shader_file.is_valid()) {
+ _update_options();
+ }
+ }
+}
+
+void ShaderFileEditor::_editor_settings_changed() {
+
+ if (is_visible_in_tree() && shader_file.is_valid()) {
+ _update_options();
+ }
+}
+
+void ShaderFileEditor::_bind_methods() {
+}
+
+void ShaderFileEditor::edit(const Ref<RDShaderFile> &p_shader) {
+
+ if (p_shader.is_null()) {
+ if (shader_file.is_valid()) {
+ shader_file->disconnect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed));
+ }
+ return;
+ }
+
+ if (shader_file == p_shader)
+ return;
+
+ shader_file = p_shader;
+
+ if (shader_file.is_valid()) {
+ shader_file->connect("changed", callable_mp(this, &ShaderFileEditor::_shader_changed));
+ }
+
+ _update_options();
+}
+
+void ShaderFileEditor::_shader_changed() {
+
+ if (is_visible_in_tree()) {
+ _update_options();
+ }
+}
+
+ShaderFileEditor *ShaderFileEditor::singleton = nullptr;
+
+ShaderFileEditor::ShaderFileEditor(EditorNode *p_node) {
+ singleton = this;
+ HSplitContainer *main_hs = memnew(HSplitContainer);
+
+ add_child(main_hs);
+
+ versions = memnew(ItemList);
+ versions->connect("item_selected", callable_mp(this, &ShaderFileEditor::_version_selected));
+ versions->set_custom_minimum_size(Size2i(200 * EDSCALE, 0));
+ main_hs->add_child(versions);
+
+ VBoxContainer *main_vb = memnew(VBoxContainer);
+ main_vb->set_h_size_flags(SIZE_EXPAND_FILL);
+ main_hs->add_child(main_vb);
+
+ static const char *stage_str[RD::SHADER_STAGE_MAX] = {
+ "Vertex",
+ "Fragment",
+ "TessControl",
+ "TessEval",
+ "Compute"
+ };
+
+ stage_hb = memnew(HBoxContainer);
+ main_vb->add_child(stage_hb);
+
+ Ref<ButtonGroup> bg;
+ bg.instance();
+ for (int i = 0; i < RD::SHADER_STAGE_MAX; i++) {
+ Button *button = memnew(Button(stage_str[i]));
+ button->set_toggle_mode(true);
+ button->set_focus_mode(FOCUS_NONE);
+ stage_hb->add_child(button);
+ stages[i] = button;
+ button->set_button_group(bg);
+ button->connect("pressed", callable_mp(this, &ShaderFileEditor::_version_selected), varray(i));
+ }
+
+ error_text = memnew(RichTextLabel);
+ error_text->set_v_size_flags(SIZE_EXPAND_FILL);
+ main_vb->add_child(error_text);
+}
+
+void ShaderFileEditorPlugin::edit(Object *p_object) {
+
+ RDShaderFile *s = Object::cast_to<RDShaderFile>(p_object);
+ shader_editor->edit(s);
+}
+
+bool ShaderFileEditorPlugin::handles(Object *p_object) const {
+
+ RDShaderFile *shader = Object::cast_to<RDShaderFile>(p_object);
+ return shader != nullptr;
+}
+
+void ShaderFileEditorPlugin::make_visible(bool p_visible) {
+
+ if (p_visible) {
+ button->show();
+ editor->make_bottom_panel_item_visible(shader_editor);
+
+ } else {
+
+ button->hide();
+ if (shader_editor->is_visible_in_tree())
+ editor->hide_bottom_panel();
+ }
+}
+
+ShaderFileEditorPlugin::ShaderFileEditorPlugin(EditorNode *p_node) {
+
+ editor = p_node;
+ shader_editor = memnew(ShaderFileEditor(p_node));
+
+ shader_editor->set_custom_minimum_size(Size2(0, 300) * EDSCALE);
+ button = editor->add_bottom_panel_item(TTR("ShaderFile"), shader_editor);
+ button->hide();
+}
+
+ShaderFileEditorPlugin::~ShaderFileEditorPlugin() {
+}
diff --git a/editor/plugins/shader_file_editor_plugin.h b/editor/plugins/shader_file_editor_plugin.h
new file mode 100644
index 0000000000..44d32de2f1
--- /dev/null
+++ b/editor/plugins/shader_file_editor_plugin.h
@@ -0,0 +1,64 @@
+#ifndef SHADER_FILE_EDITOR_PLUGIN_H
+#define SHADER_FILE_EDITOR_PLUGIN_H
+
+#include "editor/code_editor.h"
+#include "editor/editor_plugin.h"
+#include "scene/gui/menu_button.h"
+#include "scene/gui/panel_container.h"
+#include "scene/gui/rich_text_label.h"
+#include "scene/gui/tab_container.h"
+#include "scene/gui/text_edit.h"
+#include "scene/main/timer.h"
+#include "servers/rendering/rendering_device_binds.h"
+
+class ShaderFileEditor : public PanelContainer {
+
+ GDCLASS(ShaderFileEditor, PanelContainer);
+
+ Ref<RDShaderFile> shader_file;
+
+ HBoxContainer *stage_hb;
+ ItemList *versions;
+ Button *stages[RD::SHADER_STAGE_MAX];
+ RichTextLabel *error_text;
+
+ void _update_version(const StringName &p_version_txt, const RenderingDevice::ShaderStage p_stage);
+ void _version_selected(int p_stage);
+ void _editor_settings_changed();
+
+ void _update_options();
+ void _shader_changed();
+
+protected:
+ void _notification(int p_what);
+ static void _bind_methods();
+
+public:
+ static ShaderFileEditor *singleton;
+ void edit(const Ref<RDShaderFile> &p_shader);
+
+ ShaderFileEditor(EditorNode *p_node);
+};
+
+class ShaderFileEditorPlugin : public EditorPlugin {
+
+ GDCLASS(ShaderFileEditorPlugin, EditorPlugin);
+
+ ShaderFileEditor *shader_editor;
+ EditorNode *editor;
+ Button *button;
+
+public:
+ virtual String get_name() const { return "ShaderFile"; }
+ bool has_main_screen() const { return false; }
+ virtual void edit(Object *p_object);
+ virtual bool handles(Object *p_object) const;
+ virtual void make_visible(bool p_visible);
+
+ ShaderFileEditor *get_shader_editor() const { return shader_editor; }
+
+ ShaderFileEditorPlugin(EditorNode *p_node);
+ ~ShaderFileEditorPlugin();
+};
+
+#endif // SHADER_FILE_EDITOR_PLUGIN_H
diff --git a/editor/plugins/style_box_editor_plugin.cpp b/editor/plugins/style_box_editor_plugin.cpp
index fbb6616dea..eb6e261305 100644
--- a/editor/plugins/style_box_editor_plugin.cpp
+++ b/editor/plugins/style_box_editor_plugin.cpp
@@ -45,7 +45,7 @@ void EditorInspectorPluginStyleBox::parse_begin(Object *p_object) {
preview->edit(sb);
add_custom_control(preview);
}
-bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
+bool EditorInspectorPluginStyleBox::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
return false; //do not want
}
void EditorInspectorPluginStyleBox::parse_end() {
diff --git a/editor/plugins/style_box_editor_plugin.h b/editor/plugins/style_box_editor_plugin.h
index f4a72d9d1c..1eea9260b2 100644
--- a/editor/plugins/style_box_editor_plugin.h
+++ b/editor/plugins/style_box_editor_plugin.h
@@ -62,7 +62,7 @@ class EditorInspectorPluginStyleBox : public EditorInspectorPlugin {
public:
virtual bool can_handle(Object *p_object);
virtual void parse_begin(Object *p_object);
- virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
+ virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false);
virtual void parse_end();
};
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index ce421ac0a5..9e88cd8889 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -57,17 +57,18 @@ void TileMapEditor::_notification(int p_what) {
} break;
+ case NOTIFICATION_ENTER_TREE: {
+
+ get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
+ [[fallthrough]];
+ }
+
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
if (is_visible_in_tree()) {
_update_palette();
}
- [[fallthrough]];
- }
- case NOTIFICATION_ENTER_TREE: {
-
- get_tree()->connect("node_removed", callable_mp(this, &TileMapEditor::_node_removed));
paint_button->set_icon(get_theme_icon("Edit", "EditorIcons"));
bucket_fill_button->set_icon(get_theme_icon("Bucket", "EditorIcons"));
picker_button->set_icon(get_theme_icon("ColorPick", "EditorIcons"));
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 294ce2c4cd..d5128db0d5 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -2261,6 +2261,12 @@ void VisualShaderEditor::_show_preview_text() {
}
}
+static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
+
+ RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
+ return RS::global_variable_type_get_shader_datatype(gvt);
+}
+
void VisualShaderEditor::_update_preview() {
if (!preview_showed) {
@@ -2274,7 +2280,7 @@ void VisualShaderEditor::_update_preview() {
ShaderLanguage sl;
- Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types());
+ Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
for (int i = 0; i < preview_text->get_line_count(); i++) {
preview_text->set_line_as_marked(i, false);
@@ -3291,7 +3297,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) {
//do none
}
-bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
+bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) {
diff --git a/editor/plugins/visual_shader_editor_plugin.h b/editor/plugins/visual_shader_editor_plugin.h
index 473c1bb070..a495b09b5c 100644
--- a/editor/plugins/visual_shader_editor_plugin.h
+++ b/editor/plugins/visual_shader_editor_plugin.h
@@ -338,7 +338,7 @@ class EditorInspectorShaderModePlugin : public EditorInspectorPlugin {
public:
virtual bool can_handle(Object *p_object);
virtual void parse_begin(Object *p_object);
- virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage);
+ virtual bool parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide = false);
virtual void parse_end();
};