瀏覽代碼

Warning dialog is now shown if trying to set Node name to empty string

If the user tried to change a Node name to an empty string in the Scene
Tree Editor an error would be returned to console, now a warning dialog
is shown with a clear message
Silvano Cerza 7 年之前
父節點
當前提交
839f3d5eeb
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      editor/scene_tree_editor.cpp

+ 7 - 0
editor/scene_tree_editor.cpp

@@ -665,6 +665,13 @@ void SceneTreeEditor::_renamed() {
 	Node *n = get_node(np);
 	ERR_FAIL_COND(!n);
 
+	// Empty node names are not allowed, so resets it to previous text and show warning
+	if (which->get_text(0).strip_edges().empty()) {
+		which->set_text(0, n->get_name());
+		EditorNode::get_singleton()->show_warning(TTR("No name provided"));
+		return;
+	}
+
 	String new_name = which->get_text(0);
 	if (!Node::_validate_node_name(new_name)) {