Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Match Canvas with Main Camera - Unity

Tags:

I want to use the Canvas and UI Text to constantly show the score of my game on the top right corner of the screen. How can I initialize the Canvas so that its position and dimensions perfectly match the border of the camera? (2D Setup)

like image 400
Fabrizio Demaria Avatar asked Oct 12 '15 17:10

Fabrizio Demaria


People also ask

How do I make canvas and camera the same size as unity?

To see the canvas fit into the camera's size in the scene, change the Canvas component's Render Mode to Screen Space - Camera , and drag the camera from the hierarchy to it.

How do I follow the camera in unity?

Making the camera following the player is quite straight forward. Add this script to your main camera. Drag the reference of the player object to the script and then you are done. You can change the values in the Vector 3 depending on how far you want the camera to be from the player.

Can you have 2 canvases unity?

A single Canvas for all UI elements is sufficient but multiple Canvases in the scene is possible. It is also possible use nested Canvases, where one Canvas is placed as a child of another for optimization purposes. A nested Canvas uses the same Render Mode as its parent.


1 Answers

To see the canvas fit into the camera's size in the scene, change the Canvas component's Render Mode to Screen Space - Camera, and drag the camera from the hierarchy to it.

like image 84
user3071284 Avatar answered Sep 20 '22 13:09

user3071284