Godot Version
v4.3.stable.official [77dcf97d8]
Question
I'm using GraphEdit to build harness diagrams. I would like to blow this up and save as an image. Can someone point me in the right direction? Right now I just capture the viewport but to get all the nodes on screen it's much too small.
Is making an extra large subviewport possible? And do the same texture grab
I have tried the following
func _on_screenshot_button_pressed() -> void:
var ge = $GraphEdit.duplicate()
$SubViewport.add_child(ge)
$SubViewport.get_texture().get_image().save_png("user://Screenshot.png") #
but get the following errors:
E 0:00:04:0368 control.gd:36 @ _on_screenshot_button_pressed(): Index p_index = 1 is out of bounds ((int)data.children_cache.size() = 1). <C++ Source> scene/main/node.cpp:1688 @ get_child() <Stack Trace> control.gd:36 @ _on_screenshot_button_pressed()
E 0:00:04:0368 control.gd:36 @ _on_screenshot_button_pressed(): Child node disappeared while duplicating. <C++ Error> Parameter "copy_child" is null. <C++ Source> scene/main/node.cpp:2926 @ _duplicate_properties() <Stack Trace> control.gd:36 @ _on_screenshot_button_pressed()
I dont think that is how you duplicate a scene.
Try just reparenting the scene in the viewport then parent it back.
func _on_screenshot_button_pressed() -> void:
var ge = $GraphEdit
ge.reparent($SubViewport, true)
$SubViewport.get_texture().get_image().save_png("user://Screenshot.png") #
ge.reparent(self, true)