Vojtěch Struhár

Posted on March 4, 2025 | #godot

thumbnail

How to Lock Nodes in Godot Editor

Locking a node prevents selection and movement.

What a useful feature of the 3D editor! It’s available to us via the padlock icon in the 3D toolbar.

But how to lock nodes via script? It’s actually pretty easy:

node.set_meta("_edit_lock_", true)

That’s right, all it takes is to set a single metadata property. Metadata starting with an underscore are used by the editor (by convention) and are not visible in node inspector. But you are free to list and edit them all you want :)

Caution

The exact value of the metadata is an undocumented feature and could theoretically change at any moment. But it is very widely used in the Godot source code, so I doubt that will happen anytime soon.

Use case

Doing this only makes sense in a @tool script when doing some advanced plugin logic. I find it particularly useful with internal nodes.

When you create an internal node, it’s hidden from the scene tree, but it’s still selectable in the viewport. If the internal node is fully managed by your plugin locking it might be a good idea. Maybe it’s just visualizing something and you don’t want the user to interact with it directly!

Read next → Godot Rider Hide UID files