summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-10-11 09:27:27 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-10-11 09:27:27 +0200
commit56065510285f81a808a7837244fce92055c95f37 (patch)
treef9afe9927f22b32ac01d44c2c4a5d9c489cf200e
parent4d5d33f7fffe54bba9ff74b9ef9bb69bcc929c68 (diff)
parentb754df2b991bc4bb2b8157ae90cac4b8f454b9e3 (diff)
Merge pull request #67219 from KoBeWi/adJUSt_NAMe_cAsIng_PRopERLY
Fix node name casing issues
-rw-r--r--editor/scene_tree_dock.cpp9
-rw-r--r--scene/main/node.cpp4
2 files changed, 7 insertions, 6 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index acaa4ec3c9..ee358a8064 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -2176,11 +2176,15 @@ void SceneTreeDock::_selection_changed() {
void SceneTreeDock::_do_create(Node *p_parent) {
Variant c = create_dialog->instance_selected();
-
- ERR_FAIL_COND(!c);
Node *child = Object::cast_to<Node>(c);
ERR_FAIL_COND(!child);
+ String new_name = p_parent->validate_child_name(child);
+ if (GLOBAL_GET("editor/node_naming/name_casing").operator int() != NAME_CASING_PASCAL_CASE) {
+ new_name = adjust_name_casing(new_name);
+ }
+ child->set_name(new_name);
+
editor_data->get_undo_redo()->create_action_for_history(TTR("Create Node"), editor_data->get_current_edited_scene_history_id());
if (edited_scene) {
@@ -2191,7 +2195,6 @@ void SceneTreeDock::_do_create(Node *p_parent) {
editor_data->get_undo_redo()->add_do_reference(child);
editor_data->get_undo_redo()->add_undo_method(p_parent, "remove_child", child);
- String new_name = p_parent->validate_child_name(child);
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
editor_data->get_undo_redo()->add_do_method(ed, "live_debug_create_node", edited_scene->get_path_to(p_parent), child->get_class(), new_name);
editor_data->get_undo_redo()->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(p_parent)).path_join(new_name)));
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 101a63db1b..6ab27853f1 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -1024,11 +1024,9 @@ String increase_numeric_string(const String &s) {
void Node::_generate_serial_child_name(const Node *p_child, StringName &name) const {
if (name == StringName()) {
- //no name and a new name is needed, create one.
+ // No name and a new name is needed, create one.
name = p_child->get_class();
- // Adjust casing according to project setting.
- name = adjust_name_casing(name);
}
//quickly test if proposed name exists