Search code examples
c#game-engineunity-game-engine

How to make 3d viewport available within a square?


How to make 3D Viewport within that 3D viewport square

enter image description here


Solution

  • You can use the Normalized Viewport Rectangles' approach, achieved by editing the Viewport Rect of the Camera.

    enter image description here

    The Documentation explains an example of split screen for a two-player game. You can adapt the explanation having the game in a particular area, and the GUI in the other screen space.

    Normalized Viewport Rectangles

    Normalized Viewport Rectangle is specifically for defining a certain portion of the screen that the current camera view will be drawn upon. You can put a map view in the lower-right hand corner of the screen, or a missile-tip view in the upper-left corner. With a bit of design work, you can use Viewport Rectangle to create some unique behaviors.

    It’s easy to create a two-player split screen effect using Normalized Viewport Rectangle. After you have created your two cameras, change both camera’s H values to be 0.5 then set player one’s Y value to 0.5, and player two’s Y value to 0. This will make player one’s camera display from halfway up the screen to the top, and player two’s camera start at the bottom and stop halfway up the screen.

    enter image description here