Although using a second viewport can be useful in many situations, there will be times when you need to output the image rendered from a camera to a texture at runtime. To illustrate this point, in this recipe, we will make use of Render Texture to create an in-game surveillance camera that transmits its video to a monitor.
For this recipe, we have prepared the BasicScene
Unity package, containing a scene named BasicScene
, and also two FBX 3D models for the monitor and camera objects. The package is in the 1362_05_codes
folder, and the 3D models are in the 1362_05_06
folder.
To create a picture-in-picture display, just follow these steps:
Import the
BasicScene
package and themonitor
andcamera
models into your Unity Project.From the Project view, open the BasicScene level. This is a basic scene featuring an animated character and some extra geometry.
From the Project view, place the monitor and camera...