Search Unity

How can i add a camera to the game window like a preview ?

Discussion in 'Scripting' started by Chocolade, Dec 15, 2016.

  1. Chocolade

    Chocolade

    Joined:
    Jun 19, 2013
    Posts:
    933
    I mean i want to display when running the game what is going on in some other place in the scene.
    For example in the big game window i'm playing and in the small camera window on the right bottom corner it will show me what the enemy is doing for while.

    Like picture in picture tv effect.

    In the screenshot i marked with black what i mean.
    The Camera Preview in the Scene window is the Camera in the Hierarchy (Not the Main Camera )

    And i want that this Camera will be display in the game window so i can display in this camera other places in the scene while the game is running.

    In red is the Camera i want to be in the game window.





    This is a theory example image of what i mean picture in picture. The small window on the top left corner is the Camera and the big window image is the Main Camera:

     
  2. Timelog

    Timelog

    Joined:
    Nov 22, 2014
    Posts:
    528
    Easiest way would be to add the second camera in the hierachy, add and position a plane to where you want to show the second camera's capture, and apply a render texture to the plane and set that as the target texture of the camera.

     
    Kiwasi and LiterallyJeff like this.
  3. frankrs

    frankrs

    Joined:
    Aug 29, 2009
    Posts:
    300
    Another way would be to have two cameras, one with a higher render layer and then adjusting scale in the cameras settings
     
    Kiwasi likes this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This is best for square cameras.

    This is best for anything fancy.
     
    Timelog and frankrs like this.