diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp index c5b84f0af1e..2e20e068d73 100644 --- a/editor/plugins/visual_shader_editor_plugin.cpp +++ b/editor/plugins/visual_shader_editor_plugin.cpp @@ -88,7 +88,6 @@ void VisualShaderEditor::edit(VisualShader *p_visual_shader) { } else { if (changed) { // to avoid tree collapse _clear_buffer(); - _update_custom_nodes(); _update_options_menu(); _update_preview(); } @@ -178,7 +177,7 @@ bool VisualShaderEditor::_is_available(int p_mode) { return (p_mode == -1 || (p_mode & current_mode) != 0); } -void VisualShaderEditor::_update_custom_nodes() { +void VisualShaderEditor::update_custom_nodes() { clear_custom_types(); List class_list; ScriptServer::get_global_class_list(&class_list); @@ -228,6 +227,7 @@ void VisualShaderEditor::_update_custom_nodes() { add_custom_type(name, script, description, return_icon_type, category, sub_category); } } + _update_options_menu(); } String VisualShaderEditor::_get_description(int p_idx) { @@ -1219,6 +1219,23 @@ void VisualShaderEditor::_edit_port_default_input(Object *p_button, int p_node, editing_port = p_port; } +void VisualShaderEditor::_add_custom_node(const String &p_path) { + + int idx = -1; + + for (int i = custom_node_option_idx; i < add_options.size(); i++) { + if (add_options[i].script.is_valid()) { + if (add_options[i].script->get_path() == p_path) { + idx = i; + break; + } + } + } + if (idx != -1) { + _add_node(idx); + } +} + void VisualShaderEditor::_add_texture_node(const String &p_path) { VisualShaderNodeTexture *texture = (VisualShaderNodeTexture *)_add_node(texture_node_option_idx, -1); texture->set_texture(ResourceLoader::load(p_path)); @@ -2072,14 +2089,24 @@ void VisualShaderEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da } else if (d.has("files")) { if (d["files"].get_type() == Variant::POOL_STRING_ARRAY) { + int j = 0; PoolStringArray arr = d["files"]; for (int i = 0; i < arr.size(); i++) { String type = ResourceLoader::get_resource_type(arr[i]); - if (ClassDB::get_parent_class(type) == "Texture") { - saved_node_pos = p_point + Vector2(0, i * 210 * EDSCALE); + if (type == "GDScript") { + Ref