Viewport captureing

ProgManProgMan Posts: 4Member

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();

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:

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!


Tags :


  • ProgManProgMan Posts: 4Member
    edited September 6

    I don't like to answer to my own posts, but maybe this will be useful to someone. Sub-viewports works only as embeeded in "ViewportContainer" control. I have checked it and I can confirm, it works. Sub-viewport capturing does screenshot only the controls contained as it's children.

    Very important note!
    As controls embeeded as viewport children can not be managed using editor as all controls, size, anchors, placement must be done manually either as their properties or in a code.

    If someone is interested I can deliver corrected version of example!

Sign In or Register to comment.