Capsure a screenshot through the editor viewport in gdscript

Godot Version

4.2

Question

I’m making a plugin to package maps for my game and I want to be able to capture a screenshot of the editor’s camera like this


but without the gismos in the top corners. Is this possible through gdscript?

Sure, get the viewport with EditorInterface.get_editor_viewport_3d() and save its image like:

@tool
extends EditorScript

func _run() -> void:
	var viewport = EditorInterface.get_editor_viewport_3d(0)
	var img = viewport.get_texture().get_image()
	img.save_png('res://preview.png')
2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.