Repository navigation
Automating Editor Tasks
The true value of the GDGist Pro "Editor Scripts" feature lies in its ability to execute volatile, in-memory modifications to the active workspace. By directly interacting with Godot's EditorInterface, you can automate tedious scene setup and enforce project-wide structural standards without leaving a trace of tool scripts in your source control.
Below are architectural patterns demonstrating how to leverage Editor Scripts for daily development.
The most common requirement for editor automation is traversing the active scene tree to analyze or modify specific node types. Because Editor Scripts run in the active editor context, you can retrieve the scene root using get_scene().
Here is a standard traversal boilerplate you should save as a Global Gist:
@tool
extends EditorScript
func _run() -> void:
var root: Node = get_scene()
if not root:
push_error("No active scene open.")
return
_traverse_and_process(root)
print("Batch processing complete.")
func _traverse_and_process(node: Node) -> void:
# Insert your evaluation logic here
if node is Sprite2D:
# Example: Enforce Nearest filtering for pixel art projects
node.texture_filter = CanvasItem.TEXTURE_FILTER_NEAREST
for child in node.get_children():
_traverse_and_process(child)Often, you only want to operate on explicitly selected nodes rather than the entire scene tree. You can hook directly into the user's active selection via the EditorInterface.
@tool
extends EditorScript
func _run() -> void:
var interface := get_editor_interface()
var selection := interface.get_selection().get_selected_nodes()
if selection.is_empty():
push_warning("No nodes selected.")
return
for node in selection:
# Example: Strip whitespace and strictly PascalCase node names
var clean_name = node.name.replace(" ", "")
node.name = clean_nameRemember that _run() executes instantly. If you are performing destructive operations (like deleting nodes or overriding critical resource paths), ensure you utilize Godot's EditorUndoRedoManager within your script to maintain standard Ctrl+Z functionality for the user.
🔹 Home 🔹
Wiki Root
Getting Started
Working with GDGist
Pro Features
Settings
Workflows & Examples