Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canvas too big for the camera in Unity

Tags:

unity3d

I have created a 2D game with an orthogonal camera and using 16:9 display size.

I dragged my background image onto the hierarchy (it's about 2048x1152) and then set the camera size to be 22.5, which made it fit the background perfectly and displays just right.

However, when I add a Canvas for a UI it is absolutely giant, about 100 times bigger. It only becomes 'normal' size with respect everything else added when I set the camera to its default size of 5. So when I add a small graphic, it too becomes giant.

I'm simply following a book I read and I'm not doing anything to deviate.

Am I doing something wrong? Below is what I mean. The background image is the little image in the bottom right and the outlined rectangle is the canvas with a small graphic added.

Thanks.

Image

like image 445
Neil Walker Avatar asked Mar 17 '17 19:03

Neil Walker


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. Thank you!

How do I fix the canvas size in unity?

To change the screen size, go to the Game window (accessed by the menu "Window->General->Game"). At the top of the window will be a screen size menu (outlined in green, below) to change the screen size. When pressed, it will display the list of screen sizes that will be emulated.

Why I can't change the size of my canvas unity?

This means that the canvas's canvas component has it's render mode set to Screen space - overlay . This forces it to be the size of the screen. Change it to World Space and it will allow you to resize it and move it around.


1 Answers

To force your Hierarchy Canvas UI to the same resolution as the Camera View in your Unity Editor Scene window resolution (i.e. not ridiculously massive), or in other words get the Canvas to fit into the Camera size in the Scene, do the following:

  1. Set the Canvas component's Render Mode to Screen Space - Camera.
  2. Make sure you select or drag the relevant Camera from the Hierarchy to the Render Camera field in the Inspector.
like image 124
1984drum Avatar answered Sep 24 '22 18:09

1984drum