Problem moving/resizing viewport at runtime

Hello community!

I am currently trying to make a UI with a small game window inside that can be resized and moved at runtime. A visualization of what I am trying to achieve:

5174915--513596--UnityExplain.png

Firstly, is this possible? I have come quite close, but when i resize and/or move the game viewport, the following happens:

5174915--513608--unityError.PNG

The viewport does resize, but leaves a trail of overlapping images. In this setup, the UI is in screen-space-overlay and a camera is rendering the game viewport. I have read that my problem may be caused from moving the viewport over an area that is not rendered by any other camera. I have tried several things, such as having a separate camera with only render texture to represent the black area. However, I have not been able to make it work.

Hoping someone could help me resolve this issue. In advance, thank you!

I found the solution! Having a extra camera in the same display with clear flag solid color and choose the camera background color you like.