Hello! Sometimes I just need to focus on some nodes I'm working on the scene viewport.

Is there a hotkey to hide all unselected nodes in the scene? And is there a way to unhide all nodes in a scene?

Also if anyone could tell me a way to hide the navimesh overlay it would help a lot

  • Toxe and xyz replied to this.
  • Tomcat Well I just made a basic plugin skeleton that demonstrates the principle. It's easy to adapt and upgrade according to your needs. Simply check if a node has the visible property when toggling.

    @tool
    extends EditorPlugin
    
    func _input(event):
    	if event is InputEventKey and event.is_pressed() and event.keycode == KEY_H:
    		var e = get_editor_interface()
    		toggle_unselected_visibility(e.get_edited_scene_root(), e.get_selection().get_selected_nodes())
    		
    func toggle_unselected_visibility(node, selection):
    	if not node in selection:
    		if "visible" in node:
    			node.visible = not node.visible
    	for child in node.get_children():
    		toggle_unselected_visibility(child, selection)

    Also toggling via the same hotkey probably isn't the best modality as it'd mess things up when you change the selection. But again, easy to change the logic to fit your particular workflow. As a homework, someone should make a version with 2 hotkeys; one for hiding and other for showing.

    renight0 No but it'd be easy to write an editor plugin script that does it.

    renight0
    There you go. For simplicity I hardcoded hotkey H to toggle visibility of unselected nodes

    @tool
    extends EditorPlugin
    
    func _input(event):
    	if event is InputEventKey and event.is_pressed() and event.keycode == KEY_H:
    		var e = get_editor_interface()
    		toggle_unselected_visibility(e.get_edited_scene_root(), e.get_selection().get_selected_nodes())
    		
    func toggle_unselected_visibility(node, selection):
    	if not node in selection:
    		node.visible = not node.visible
    	for child in node.get_children():
    		toggle_unselected_visibility(child, selection)

      xyz Thank you @xyz ! I have never added a plugin to a godot project. I have searched on how to add a hotkey script like this but could not find. Could you explain how can I do this?

      • xyz replied to this.

        renight0 Project Settings -> Plugins -> Create New Plugin. Fill in the details and Godot will create a new boilerplate script. Paste the code and you're done.

          xyz Hm... it did not work here. I think I did something wrong.

          • xyz replied to this.

            xyz There you go.

            If there is an undisplayed node in the project, the script gives an error. But it continues to work. In my case — "Timer":

            res://addons/hideunselectednodes/hide_unselected_nodes.gd:11 - Invalid get index 'visible' (on base: 'Timer').
            • xyz replied to this.

              Tomcat Well I just made a basic plugin skeleton that demonstrates the principle. It's easy to adapt and upgrade according to your needs. Simply check if a node has the visible property when toggling.

              @tool
              extends EditorPlugin
              
              func _input(event):
              	if event is InputEventKey and event.is_pressed() and event.keycode == KEY_H:
              		var e = get_editor_interface()
              		toggle_unselected_visibility(e.get_edited_scene_root(), e.get_selection().get_selected_nodes())
              		
              func toggle_unselected_visibility(node, selection):
              	if not node in selection:
              		if "visible" in node:
              			node.visible = not node.visible
              	for child in node.get_children():
              		toggle_unselected_visibility(child, selection)

              Also toggling via the same hotkey probably isn't the best modality as it'd mess things up when you change the selection. But again, easy to change the logic to fit your particular workflow. As a homework, someone should make a version with 2 hotkeys; one for hiding and other for showing.