How to set Camera View a Specific Area in UI

Viewed 2943

My all project works in UI. One of my scene has videoPlayer and I would like to set my MainCamera to that specific Area. This scene is my Recording scene but for recording I have to use canvas Render Mode and has to be "Screen Space - Camera". How I can set my camera view to that specific area. I tried 2nd camera with culling mask but didn't work because videoplayer is already my UI's child when camera Renders UI showing all children objects.

Is it possible show to camera whereever I want in UI?

enter image description here

1 Answers

Yessir it sure is. I literally had to do this a couple of days ago. Here is a tutorial/video I followed to figure out how to do it for my application. From the sounds of it, all you need to do is follow the video up to ~3 minutes. Then utilize the end product of getting a camera to showcase something in a UI window for your application.

For reference if the video gets deleted the process is as follows:

  1. Create a new GameObject within the Canvas
  2. Add a Raw Image as a child to to the new GameObject

We want a raw image because Raw Images in particular support the addition of a 2d Texture and this is what we need in order to display the Camera view.

  1. Add a new Camera as a child to the GameObject
  2. Create a new Render Texture in you Project Folder
  3. Add the Render Texture to your Camera's Camera Component in the Target Texture field
  4. Add the Render Texture to you Images Raw Image Component in the Texture field
  5. Move the Camera to what you want to view and it should project to your UI GameObject.
  6. If it doesn't do this correctly or the image has weird aspect ratios, check the dimensions in the Render Texture and your Image. It took me a while to get everything to look normal but it really just takes dimension adjustments.

Hope this helps!

Related