Skip to content

Commit 117d66b

Browse files
Mohamad Al Kotobrealkotob
authored andcommitted
Add editor setting for instantiated scenes to have editable children by default
1 parent f94bbfc commit 117d66b

5 files changed

Lines changed: 21 additions & 0 deletions

File tree

doc/classes/EditorSettings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,9 @@
320320
<member name="docks/scene_tree/hide_filtered_out_parents" type="bool" setter="" getter="">
321321
If [code]true[/code], the scene tree dock will only show nodes that match the filter, without showing parents that don't. This settings can also be changed in the Scene dock's top menu.
322322
</member>
323+
<member name="docks/scene_tree/enable_editable_children_by_default" type="bool" setter="" getter="">
324+
If [code]true[/code], instantiated nodes will automatically have Editable Children set to [code]true[/code] in the scene tree dock.
325+
</member>
323326
<member name="docks/scene_tree/start_create_dialog_fully_expanded" type="bool" setter="" getter="">
324327
If [code]true[/code], the Create dialog (Create New Node/Create New Resource) will start with all its sections expanded. Otherwise, sections will be collapsed until the user starts searching (which will automatically expand sections as needed).
325328
</member>

editor/docks/scene_tree_dock.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N
364364
undo_redo->create_action_for_history(TTRN("Instantiate Scene", "Instantiate Scenes", instances.size()), editor_data->get_current_edited_scene_history_id());
365365
undo_redo->add_do_method(editor_selection, "clear");
366366

367+
bool enable_editable_children_by_default = EDITOR_GET("docks/scene_tree/enable_editable_children_by_default");
368+
367369
for (int i = 0; i < instances.size(); i++) {
368370
Node *instantiated_scene = instances[i];
369371

@@ -376,6 +378,11 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N
376378
undo_redo->add_do_reference(instantiated_scene);
377379
undo_redo->add_undo_method(p_parent, "remove_child", instantiated_scene);
378380

381+
if (enable_editable_children_by_default) {
382+
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_editable_instance", instantiated_scene, true);
383+
undo_redo->add_do_method(instantiated_scene, "set_display_folded", true);
384+
}
385+
379386
String new_name = p_parent->validate_child_name(instantiated_scene);
380387
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
381388
undo_redo->add_do_method(ed, "live_debug_instantiate_node", edited_scene->get_path_to(p_parent), p_files[i], new_name);

editor/scene/3d/node_3d_editor_plugin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5718,6 +5718,11 @@ bool Node3DEditorViewport::_create_instance(Node *p_parent, const String &p_path
57185718
undo_redo->add_undo_method(p_parent, "remove_child", instantiated_scene);
57195719
undo_redo->add_do_method(editor_selection, "add_node", instantiated_scene);
57205720

5721+
if (EDITOR_GET("docks/scene_tree/enable_editable_children_by_default")) {
5722+
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_editable_instance", instantiated_scene, true);
5723+
undo_redo->add_do_method(instantiated_scene, "set_display_folded", true);
5724+
}
5725+
57215726
String new_name = p_parent->validate_child_name(instantiated_scene);
57225727
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
57235728
undo_redo->add_do_method(ed, "live_debug_instantiate_node", EditorNode::get_singleton()->get_edited_scene()->get_path_to(p_parent), p_path, new_name);

editor/scene/canvas_item_editor_plugin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6421,6 +6421,11 @@ bool CanvasItemEditorViewport::_create_instance(Node *p_parent, const String &p_
64216421
undo_redo->add_undo_method(p_parent, "remove_child", instantiated_scene);
64226422
undo_redo->add_do_method(editor_selection, "add_node", instantiated_scene);
64236423

6424+
if (EDITOR_GET("docks/scene_tree/enable_editable_children_by_default")) {
6425+
undo_redo->add_do_method(EditorNode::get_singleton()->get_edited_scene(), "set_editable_instance", instantiated_scene, true);
6426+
undo_redo->add_do_method(instantiated_scene, "set_display_folded", true);
6427+
}
6428+
64246429
String new_name = p_parent->validate_child_name(instantiated_scene);
64256430
EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
64266431
undo_redo->add_do_method(ed, "live_debug_instantiate_node", edited_scene->get_path_to(p_parent), p_path, new_name);

editor/settings/editor_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
710710
_initial_set("docks/scene_tree/center_node_on_reparent", false);
711711
_initial_set("docks/scene_tree/hide_filtered_out_parents", true);
712712
_initial_set("docks/scene_tree/accessibility_warnings", false);
713+
_initial_set("docks/scene_tree/enable_editable_children_by_default", false);
713714

714715
// FileSystem
715716
EDITOR_SETTING(Variant::INT, PROPERTY_HINT_RANGE, "docks/filesystem/thumbnail_size", 64, "32,128,16")

0 commit comments

Comments
 (0)