- Home /
Is it possible to have my UI not overlap my camera?
Hi there,
I am having a bit of trouble trying to build a certain UI for my 2D "Function Rider" game, here's a mockup of what I am trying to do.
As you see, I have 4 main UI zones surrounding my game that I've reproduced in Unity using a Canvas and 4 panels.
What I would like to do now is to have my game's world camera to be restricted to the white square in the middle so it would be easier for me to manage the positions of the world space. The problem is that if I play with the Viewport Rect of the camera so that it matches that middle rectangle's position and size, the canvas doesn't quite display correctly. Since a Canvas is displayed on top and not around a camera.
I have tried building my game entirely inside the Canvas, but since I need a Line Renderer and that component isn't available as a UI component I'll have to make the game with regular game objects.
What options do I have that would let me do what I am trying to achieve?
Answer by Happeloy · May 18, 2018 at 12:38 PM
One thing you could do is to create a Raw Image in the main game canvas UI, and then make a camera render to a render texture, and set that texture as the image for the raw image.
The result of that would be that the middle part of your canvas would behave like a TV screen, showing the content of the game camera.