Hello everyone,
I have spent a lot of time on this and I was watching probably all tutorials on youtube, no positive results yet. Can somebody help me to set up the custom viewport for control and to capture screenshot from it?
The issue is obvious to be solved if a global viewport is used, then it using three lines:
var test_img = get_viewport().get_texture().get_data();
test_img.flip_y();
test_img.save_png("root.png");
The task is more complicated (for me at least) if screenshot of only one control is required, for example “Panel” control. Please look at enclosed code at link:
https://drive.google.com/file/d/1rDAjb3QY4N1ZQV36fu5QUPwHNHVfVS0d/view?usp=sharing
Quick description: I have created three panels, each of them contains label and additionally circle is drawn on it. On one of the panels as a child the viewport is added. Added viewport has a child. Using this viewport I wanted to capture the screen. Task is to get a screenshot (to capture) of only one control “Panel” type (not entire screenshot – this I can). In enclosed example I wanted to capture “vp_p” panel, it was a intension of using additional viewport as child of a “p3”.
A button downside captures all viewports and saves them as *.png files in local directory.
I hope someone of you can help me. Thanks in advance!