Ver Fonte

Use node name as default filename when attaching script.

When attaching a script to a node that isn't saved to a scene file,
use its name as default filename. If the edited scene's root node *has*
been saved to a file, use that directory.
Benjamin há 7 anos atrás
pai
commit
2b82997052
1 ficheiros alterados com 8 adições e 0 exclusões
  1. 8 0
      editor/scene_tree_dock.cpp

+ 8 - 0
editor/scene_tree_dock.cpp

@@ -319,6 +319,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
 				editor->push_item(existing.ptr());
 				editor->push_item(existing.ptr());
 			else {
 			else {
 				String path = selected->get_filename();
 				String path = selected->get_filename();
+				if (path == "") {
+					String root_path = editor_data->get_edited_scene_root()->get_filename();
+					if (root_path == "") {
+						path = "res://" + selected->get_name();
+					} else {
+						path = root_path.get_base_dir() + "/" + selected->get_name();
+					}
+				}
 				script_create_dialog->config(selected->get_class(), path);
 				script_create_dialog->config(selected->get_class(), path);
 				script_create_dialog->popup_centered();
 				script_create_dialog->popup_centered();
 			}
 			}