Is it possible to change multible nodes at once?

Godot Version

4.6.1

Question

I’m trying to change all of my meshes materials into a different one, without changing the files themselves. However I have hundreds of these nodes and while I can select multiple, I have to do it by “Ctrl+A” and so can only add one at a time. It would be preferable to have something that could select all of a specific type of node instead of doing it all manually. Is this achievable?

You can write a small tool script and run it in the editor.

In the search bar you can search for specific node types like this:

t:Sprite2D

This will filter nodes to only Sprite2D, then you can select with Ctrl+A

I made a mistake in the original post, “Ctrl+A” just adds a node to the scene tree, what I do is hold down “Ctrl” and manually click on each node to select multiple. So while what you provide is somewhat useful, I still have to add each node manually.

What I am trying to do is have something that can select, in the editor, all nodes that are in the “Scene” tab I have open. So using the search tool does limit the nodes to only those I want to select, but still doesn’t solve actually selecting them all.

Looking at the editor’s settings, there doesn’t appear to be a command under “Scene tree” that does what I want it to, so maybe it’s just not possible?

I’ll repeat; tool script is the way to solve problems like this.

I have been exploring that but I’m not sure how to code in what I want the editor to do. It’s an entirely new area for me and there isn’t a lot of clear documentation online for what specifically I’m asking for. Could you maybe give a code block of what I should have the script do?

Describe exactly what you want to do.

I want to be able to select all nodes, at once, that are currently visible in the “Scene” tab in the editor. By visible I also mean those I have to scroll to see on my screen. By select I mean the same as clicking on the node, having the white highlight appear on it’s name.

@tool extends EditorScript

func _run():
	for node in EditorInterface.get_edited_scene_root().get_parent().find_children("*", "", true, false):
		EditorInterface.get_selection().add_node(node)

This doesn’t account for the “Filter Nodes” search feature.

You said you want to select all of the nodes. I asked you to describe exactly what you want. You didn’t mention anything about filtering.

Nevertheless you can filter with this. Look at the Node::find_children() method description in Node class reference. The first argument is in fact a name filter string and the second one is a node type filter.

Sorry about earlier. Either way, I don’t know how to get the value of the search bar to put into the find_children part of the code. There doesn’t seem to be anything relevant when using the “EditorInterface” class.

find_children() has nothing to do with EditorInterface. It’s a method of Node class. You use it the same way you’d use it in a regular runtime script. What exactly do you want to filter?

I want to filter all nodes that aren’t appearing in the “Scene” tab. For example, if I type in “t:MeshInstance3D” into the “Filter Nodes” search bar, then only those type of Nodes will appear. Then when I run the script, I only want those Nodes to be selected, nothing else.

What I was asking in my last post was me getting the value of the “Filter Nodes”, and then putting it into the script. Otherwise I would have to put in my search into the script itself manually every time, which would be tedious.

You can filter and shift-click to select everything between two points, for example clicking the top most node and shift-clicking the bottom most will select everything

I don’t get where’s the problem then. Type the filter in the filter filed and select everything by clicking as described by @gertkeno.

I thought you wanted to perform some more or less complex operation on those nodes. If you only want to selected them - clickity click.

Thank you so much! This is works well enough.

Note that this falls under basic computer usage literacy. Every single list in every single program on your computer lets you select like this.

I have never had the need for something like this before, as file managers have those square highlighting things.

Now you know :nerd_face: . This convention is even used in other standard gui contexts when a range needs to be selected - like a range of cells in Excel or a text range in Word or Notepad.