summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/animation_track_editor.cpp16
-rw-r--r--editor/code_editor.cpp42
-rw-r--r--editor/editor_data.cpp10
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/editor_settings_dialog.cpp2
-rw-r--r--editor/editor_themes.cpp75
-rw-r--r--editor/import/resource_importer_scene.cpp2
-rw-r--r--editor/plugins/mesh_instance_3d_editor_plugin.cpp10
-rw-r--r--editor/plugins/tiles/tile_data_editors.cpp1
-rw-r--r--editor/scene_tree_dock.cpp10
10 files changed, 104 insertions, 67 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp
index 7aa06e6398..957efceaa8 100644
--- a/editor/animation_track_editor.cpp
+++ b/editor/animation_track_editor.cpp
@@ -3849,7 +3849,7 @@ void AnimationTrackEditor::insert_transform_key(Node3D *p_node, const String &p_
}
// Let's build a node path.
- String path = root->get_path_to(p_node);
+ String path = root->get_path_to(p_node, true);
if (!p_sub.is_empty()) {
path += ":" + p_sub;
}
@@ -3889,7 +3889,7 @@ bool AnimationTrackEditor::has_track(Node3D *p_node, const String &p_sub, const
}
// Let's build a node path.
- String path = root->get_path_to(p_node);
+ String path = root->get_path_to(p_node, true);
if (!p_sub.is_empty()) {
path += ":" + p_sub;
}
@@ -3937,11 +3937,10 @@ void AnimationTrackEditor::_insert_animation_key(NodePath p_path, const Variant
void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_property, const Variant &p_value, bool p_only_if_exists) {
ERR_FAIL_COND(!root);
- // Let's build a node path.
+ // Let's build a node path.
Node *node = p_node;
-
- String path = root->get_path_to(node);
+ String path = root->get_path_to(node, true);
if (Object::cast_to<AnimationPlayer>(node) && p_property == "current_animation") {
if (node == AnimationPlayerEditor::get_singleton()->get_player()) {
@@ -4035,14 +4034,13 @@ void AnimationTrackEditor::insert_value_key(const String &p_property, const Vari
EditorSelectionHistory *history = EditorNode::get_singleton()->get_editor_selection_history();
ERR_FAIL_COND(!root);
- // Let's build a node path.
ERR_FAIL_COND(history->get_path_size() == 0);
Object *obj = ObjectDB::get_instance(history->get_path_object(0));
ERR_FAIL_COND(!Object::cast_to<Node>(obj));
+ // Let's build a node path.
Node *node = Object::cast_to<Node>(obj);
-
- String path = root->get_path_to(node);
+ String path = root->get_path_to(node, true);
if (Object::cast_to<AnimationPlayer>(node) && p_property == "current_animation") {
if (node == AnimationPlayerEditor::get_singleton()->get_player()) {
@@ -4826,7 +4824,7 @@ void AnimationTrackEditor::_new_track_node_selected(NodePath p_path) {
ERR_FAIL_COND(!root);
Node *node = get_node(p_path);
ERR_FAIL_COND(!node);
- NodePath path_to = root->get_path_to(node);
+ NodePath path_to = root->get_path_to(node, true);
if (adding_track_type == Animation::TYPE_BLEND_SHAPE && !node->is_class("MeshInstance3D")) {
EditorNode::get_singleton()->show_warning(TTR("Blend Shape tracks only apply to MeshInstance3D nodes."));
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index e907d5a281..65cb083ac7 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -2002,23 +2002,14 @@ void CodeTextEditor::goto_next_bookmark() {
return;
}
- text_editor->remove_secondary_carets();
- int line = text_editor->get_caret_line();
- if (line >= (int)bmarks[bmarks.size() - 1]) {
- text_editor->unfold_line(bmarks[0]);
- text_editor->set_caret_line(bmarks[0]);
- text_editor->center_viewport_to_caret();
- } else {
- for (int i = 0; i < bmarks.size(); i++) {
- int bmark_line = bmarks[i];
- if (bmark_line > line) {
- text_editor->unfold_line(bmark_line);
- text_editor->set_caret_line(bmark_line);
- text_editor->center_viewport_to_caret();
- return;
- }
+ int current_line = text_editor->get_caret_line();
+ int bmark_idx = 0;
+ if (current_line < (int)bmarks[bmarks.size() - 1]) {
+ while (bmark_idx < bmarks.size() && bmarks[bmark_idx] <= current_line) {
+ bmark_idx++;
}
}
+ goto_line_centered(bmarks[bmark_idx]);
}
void CodeTextEditor::goto_prev_bookmark() {
@@ -2027,23 +2018,14 @@ void CodeTextEditor::goto_prev_bookmark() {
return;
}
- text_editor->remove_secondary_carets();
- int line = text_editor->get_caret_line();
- if (line <= (int)bmarks[0]) {
- text_editor->unfold_line(bmarks[bmarks.size() - 1]);
- text_editor->set_caret_line(bmarks[bmarks.size() - 1]);
- text_editor->center_viewport_to_caret();
- } else {
- for (int i = bmarks.size() - 1; i >= 0; i--) {
- int bmark_line = bmarks[i];
- if (bmark_line < line) {
- text_editor->unfold_line(bmark_line);
- text_editor->set_caret_line(bmark_line);
- text_editor->center_viewport_to_caret();
- return;
- }
+ int current_line = text_editor->get_caret_line();
+ int bmark_idx = bmarks.size() - 1;
+ if (current_line > (int)bmarks[0]) {
+ while (bmark_idx >= 0 && bmarks[bmark_idx] >= current_line) {
+ bmark_idx--;
}
}
+ goto_line_centered(bmarks[bmark_idx]);
}
void CodeTextEditor::remove_all_bookmarks() {
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 48be0c9c00..f15b874c45 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -945,11 +945,11 @@ StringName EditorData::script_class_get_base(const String &p_class) const {
Variant EditorData::script_class_instance(const String &p_class) {
if (ScriptServer::is_global_class(p_class)) {
- Variant obj = ClassDB::instantiate(ScriptServer::get_global_class_native_base(p_class));
- if (obj) {
- Ref<Script> script = script_class_load_script(p_class);
- if (script.is_valid()) {
- ((Object *)obj)->set_script(script);
+ Ref<Script> script = script_class_load_script(p_class);
+ if (script.is_valid()) {
+ Object *obj = ClassDB::instantiate(script->get_instance_base_type());
+ if (obj) {
+ obj->set_script(script);
}
return obj;
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bc186c7a16..c44fe04442 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -452,11 +452,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/inspector/show_low_level_opentype_features", false, "")
// Theme
- EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", "Default", "Default,Breeze Dark,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Custom")
+ EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_ENUM, "interface/theme/preset", "Default", "Default,Breeze Dark,Godot 2,Gray,Light,Solarized (Dark),Solarized (Light),Black (OLED),Custom")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_ENUM, "interface/theme/icon_and_font_color", 0, "Auto,Dark,Light")
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/base_color", Color(0.2, 0.23, 0.31), "")
EDITOR_SETTING(Variant::COLOR, PROPERTY_HINT_NONE, "interface/theme/accent_color", Color(0.41, 0.61, 0.91), "")
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/contrast", 0.3, "-1,1,0.01")
+ EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/theme/draw_extra_borders", false, "")
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/icon_saturation", 1.0, "0,2,0.01")
EDITOR_SETTING(Variant::FLOAT, PROPERTY_HINT_RANGE, "interface/theme/relationship_line_opacity", 0.1, "0.00,1,0.01")
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "interface/theme/border_size", 0, "0,2,1")
diff --git a/editor/editor_settings_dialog.cpp b/editor/editor_settings_dialog.cpp
index b1b54fd717..6c11572d10 100644
--- a/editor/editor_settings_dialog.cpp
+++ b/editor/editor_settings_dialog.cpp
@@ -61,7 +61,7 @@ void EditorSettingsDialog::_settings_changed() {
void EditorSettingsDialog::_settings_property_edited(const String &p_name) {
String full_name = inspector->get_full_item_path(p_name);
- if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast") {
+ if (full_name == "interface/theme/accent_color" || full_name == "interface/theme/base_color" || full_name == "interface/theme/contrast" || full_name == "interface/theme/draw_extra_borders") {
EditorSettings::get_singleton()->set_manually("interface/theme/preset", "Custom"); // set preset to Custom
} else if (full_name.begins_with("text_editor/theme/highlighting")) {
EditorSettings::get_singleton()->set_manually("text_editor/theme/color_theme", "Custom");
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index df28b2e6ab..96834f4a6c 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -393,6 +393,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Color accent_color = EDITOR_GET("interface/theme/accent_color");
Color base_color = EDITOR_GET("interface/theme/base_color");
float contrast = EDITOR_GET("interface/theme/contrast");
+ bool draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");
float icon_saturation = EDITOR_GET("interface/theme/icon_saturation");
float relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
@@ -404,6 +405,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Color preset_accent_color;
Color preset_base_color;
float preset_contrast = 0;
+ bool preset_draw_extra_borders = false;
const float default_contrast = 0.3;
@@ -440,6 +442,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
preset_base_color = Color(0.89, 0.86, 0.79);
// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
preset_contrast = -0.08;
+ } else if (preset == "Black (OLED)") {
+ preset_accent_color = Color(0.45, 0.75, 1.0);
+ preset_base_color = Color(0, 0, 0);
+ // The contrast rate value is irrelevant on a fully black theme.
+ preset_contrast = 0.0;
+ preset_draw_extra_borders = true;
} else { // Default
preset_accent_color = Color(0.44, 0.73, 0.98);
preset_base_color = Color(0.21, 0.24, 0.29);
@@ -450,15 +458,18 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
accent_color = preset_accent_color;
base_color = preset_base_color;
contrast = preset_contrast;
+ draw_extra_borders = preset_draw_extra_borders;
EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", accent_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", base_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", contrast);
+ EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", draw_extra_borders);
}
EditorSettings::get_singleton()->set_manually("interface/theme/preset", preset);
EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", accent_color);
EditorSettings::get_singleton()->set_manually("interface/theme/base_color", base_color);
EditorSettings::get_singleton()->set_manually("interface/theme/contrast", contrast);
+ EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", draw_extra_borders);
// Colors
bool dark_theme = EditorSettings::get_singleton()->is_dark_theme();
@@ -477,6 +488,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color dark_color_2 = base_color.lerp(Color(0, 0, 0, 1), contrast * 1.5).clamp();
const Color dark_color_3 = base_color.lerp(Color(0, 0, 0, 1), contrast * 2).clamp();
+ // Only used when the Draw Extra Borders editor setting is enabled.
+ const Color extra_border_color_1 = Color(0.5, 0.5, 0.5);
+ const Color extra_border_color_2 = dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);
+
const Color background_color = dark_color_2;
// White (dark theme) or black (light theme), will be used to generate the rest of the colors
@@ -489,7 +504,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color font_hover_color = mono_color.lerp(base_color, 0.125);
const Color font_focus_color = mono_color.lerp(base_color, 0.125);
const Color font_hover_pressed_color = font_hover_color.lerp(accent_color, 0.74);
- const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.3);
+ const Color font_disabled_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.35);
const Color font_readonly_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.65);
const Color font_placeholder_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.6);
const Color selection_color = accent_color * Color(1, 1, 1, 0.4);
@@ -634,10 +649,19 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_widget = style_default->duplicate();
style_widget->set_default_margin_individual(widget_default_margin.x, widget_default_margin.y, widget_default_margin.x, widget_default_margin.y);
style_widget->set_bg_color(dark_color_1);
- style_widget->set_border_color(dark_color_2);
+ if (draw_extra_borders) {
+ style_widget->set_border_width_all(Math::round(EDSCALE));
+ style_widget->set_border_color(extra_border_color_1);
+ } else {
+ style_widget->set_border_color(dark_color_2);
+ }
Ref<StyleBoxFlat> style_widget_disabled = style_widget->duplicate();
- style_widget_disabled->set_border_color(disabled_color);
+ if (draw_extra_borders) {
+ style_widget_disabled->set_border_color(extra_border_color_2);
+ } else {
+ style_widget_disabled->set_border_color(disabled_color);
+ }
style_widget_disabled->set_bg_color(disabled_bg_color);
Ref<StyleBoxFlat> style_widget_focus = style_widget->duplicate();
@@ -650,7 +674,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_widget_hover = style_widget->duplicate();
style_widget_hover->set_bg_color(mono_color * Color(1, 1, 1, 0.11));
- style_widget_hover->set_border_color(mono_color * Color(1, 1, 1, 0.05));
+ if (draw_extra_borders) {
+ style_widget_hover->set_border_color(extra_border_color_1);
+ } else {
+ style_widget_hover->set_border_color(mono_color * Color(1, 1, 1, 0.05));
+ }
// Style for windows, popups, etc..
Ref<StyleBoxFlat> style_popup = style_default->duplicate();
@@ -991,7 +1019,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
style_popup_menu->set_default_margin_individual(EDSCALE, 2 * EDSCALE, EDSCALE, 2 * EDSCALE);
// Always display a border for PopupMenus so they can be distinguished from their background.
style_popup_menu->set_border_width_all(EDSCALE);
- style_popup_menu->set_border_color(dark_color_2);
+ if (draw_extra_borders) {
+ style_popup_menu->set_border_color(extra_border_color_2);
+ } else {
+ style_popup_menu->set_border_color(dark_color_2);
+ }
theme->set_stylebox("panel", "PopupMenu", style_popup_menu);
Ref<StyleBoxFlat> style_menu_hover = style_widget_hover->duplicate();
@@ -1111,7 +1143,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
Ref<StyleBoxFlat> style_tree_bg = style_default->duplicate();
// Make Trees easier to distinguish from other controls by using a darker background color.
style_tree_bg->set_bg_color(dark_color_1.lerp(dark_color_2, 0.5));
- style_tree_bg->set_border_color(dark_color_3);
+ if (draw_extra_borders) {
+ style_tree_bg->set_border_width_all(Math::round(EDSCALE));
+ style_tree_bg->set_border_color(extra_border_color_2);
+ } else {
+ style_tree_bg->set_border_color(dark_color_3);
+ }
+
theme->set_stylebox("panel", "Tree", style_tree_bg);
// Tree
@@ -1207,8 +1245,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// ItemList
Ref<StyleBoxFlat> style_itemlist_bg = style_default->duplicate();
style_itemlist_bg->set_bg_color(dark_color_1);
- style_itemlist_bg->set_border_width_all(border_width);
- style_itemlist_bg->set_border_color(dark_color_3);
+
+ if (draw_extra_borders) {
+ style_itemlist_bg->set_border_width_all(Math::round(EDSCALE));
+ style_itemlist_bg->set_border_color(extra_border_color_2);
+ } else {
+ style_itemlist_bg->set_border_width_all(border_width);
+ style_itemlist_bg->set_border_color(dark_color_3);
+ }
Ref<StyleBoxFlat> style_itemlist_cursor = style_default->duplicate();
style_itemlist_cursor->set_draw_center(false);
@@ -1326,14 +1370,21 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// The original style_widget style has an extra 1 pixel offset that makes LineEdits not align with Buttons,
// so this compensates for that.
style_line_edit->set_default_margin(SIDE_TOP, style_line_edit->get_default_margin(SIDE_TOP) - 1 * EDSCALE);
- // Add a bottom line to make LineEdits more visible, especially in sectioned inspectors
- // such as the Project Settings.
- style_line_edit->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
- style_line_edit->set_border_color(dark_color_2);
+
// Don't round the bottom corner to make the line look sharper.
style_tab_selected->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
style_tab_selected->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
+ if (draw_extra_borders) {
+ style_line_edit->set_border_width_all(Math::round(EDSCALE));
+ style_line_edit->set_border_color(extra_border_color_1);
+ } else {
+ // Add a bottom line to make LineEdits more visible, especially in sectioned inspectors
+ // such as the Project Settings.
+ style_line_edit->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
+ style_line_edit->set_border_color(dark_color_2);
+ }
+
Ref<StyleBoxFlat> style_line_edit_disabled = style_line_edit->duplicate();
style_line_edit_disabled->set_border_color(disabled_color);
style_line_edit_disabled->set_bg_color(disabled_bg_color);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index f7a3ce2679..ffe6954484 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -355,7 +355,7 @@ static void _pre_gen_shape_list(Ref<ImporterMesh> &mesh, Vector<Ref<Shape3D>> &r
ERR_FAIL_NULL_MSG(mesh, "Cannot generate shape list with null mesh value");
ERR_FAIL_NULL_MSG(mesh->get_mesh(), "Cannot generate shape list with null mesh value");
if (!p_convex) {
- Ref<Shape3D> shape = mesh->create_trimesh_shape();
+ Ref<ConcavePolygonShape3D> shape = mesh->create_trimesh_shape();
r_shape_list.push_back(shape);
} else {
Vector<Ref<Shape3D>> cd;
diff --git a/editor/plugins/mesh_instance_3d_editor_plugin.cpp b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
index 68fbce771a..420c8dfde0 100644
--- a/editor/plugins/mesh_instance_3d_editor_plugin.cpp
+++ b/editor/plugins/mesh_instance_3d_editor_plugin.cpp
@@ -38,6 +38,8 @@
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/physics_body_3d.h"
#include "scene/gui/box_container.h"
+#include "scene/resources/concave_polygon_shape_3d.h"
+#include "scene/resources/convex_polygon_shape_3d.h"
void MeshInstance3DEditor::_node_removed(Node *p_node) {
if (p_node == node) {
@@ -66,7 +68,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
List<Node *> selection = editor_selection->get_selected_node_list();
if (selection.is_empty()) {
- Ref<Shape3D> shape = mesh->create_trimesh_shape();
+ Ref<ConcavePolygonShape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a Trimesh collision shape."));
err_dialog->popup_centered();
@@ -105,7 +107,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
continue;
}
- Ref<Shape3D> shape = m->create_trimesh_shape();
+ Ref<ConcavePolygonShape3D> shape = m->create_trimesh_shape();
if (shape.is_null()) {
continue;
}
@@ -137,7 +139,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
return;
}
- Ref<Shape3D> shape = mesh->create_trimesh_shape();
+ Ref<ConcavePolygonShape3D> shape = mesh->create_trimesh_shape();
if (shape.is_null()) {
return;
}
@@ -171,7 +173,7 @@ void MeshInstance3DEditor::_menu_option(int p_option) {
bool simplify = (p_option == MENU_OPTION_CREATE_SIMPLIFIED_CONVEX_COLLISION_SHAPE);
- Ref<Shape3D> shape = mesh->create_convex_shape(true, simplify);
+ Ref<ConvexPolygonShape3D> shape = mesh->create_convex_shape(true, simplify);
if (shape.is_null()) {
err_dialog->set_text(TTR("Couldn't create a single convex collision shape."));
diff --git a/editor/plugins/tiles/tile_data_editors.cpp b/editor/plugins/tiles/tile_data_editors.cpp
index 44b8ff05d1..75ef40422c 100644
--- a/editor/plugins/tiles/tile_data_editors.cpp
+++ b/editor/plugins/tiles/tile_data_editors.cpp
@@ -851,6 +851,7 @@ GenericTilePolygonEditor::GenericTilePolygonEditor() {
void TileDataDefaultEditor::_property_value_changed(StringName p_property, Variant p_value, StringName p_field) {
ERR_FAIL_COND(!dummy_object);
dummy_object->set(p_property, p_value);
+ emit_signal(SNAME("needs_redraw"));
}
Variant TileDataDefaultEditor::_get_painted_value() {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 9c3ef4cecc..fae8fdcd14 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1153,11 +1153,13 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (TOOL_CREATE_FAVORITE == p_tool) {
String name = selected_favorite_root.get_slicec(' ', 0);
if (ScriptServer::is_global_class(name)) {
- new_node = Object::cast_to<Node>(ClassDB::instantiate(ScriptServer::get_global_class_native_base(name)));
Ref<Script> scr = ResourceLoader::load(ScriptServer::get_global_class_path(name), "Script");
- if (new_node && scr.is_valid()) {
- new_node->set_script(scr);
- new_node->set_name(name);
+ if (scr.is_valid()) {
+ new_node = Object::cast_to<Node>(ClassDB::instantiate(scr->get_instance_base_type()));
+ if (new_node) {
+ new_node->set_script(scr);
+ new_node->set_name(name);
+ }
}
} else {
new_node = Object::cast_to<Node>(ClassDB::instantiate(selected_favorite_root));