Reputation: 35
I am relatively new to Unity and have been following a Udemy course for 2D game programming. One thing that stuck into my mind is that we have created a giant canvas compared to the camera, yet it shows the entire canvas when I start the game. What is the point of camera location/size if it is going to render the entire canvas? To be more specific, what is the relation between camera and canvas?
I researched and learned that we could change the Render Mode of canvas to fit the same size as the camera, thus eliminating the problem. Still didn't really understand why and how they both seem to work.
Here is a picture to demonstrate what I mean:
Upvotes: 2
Views: 4770
Reputation: 2187
With Canvas Render Mode to Screen Space - Camera the size of the canvas will always be based on Plane distance value.
Now if you want a canvas that expands beyond what camera can see then you'll have to make sub-canvas under the main canvas that you can then resize and move however you wish.
Upvotes: 1
Reputation: 1690
Your canvas is set to screen space overlay, which means it renders on top of everything that the camera/s render onto the screen. So it has no relation with the camera and it's size will depend on game view or display resolution.
Screen space camera will make it so that it will render on top of everything else on a specific camera and it'll resize with the camera.
And world space will put the canvas in the world like any other GameObject.
https://docs.unity3d.com/Packages/[email protected]/manual/UICanvas.html
Upvotes: 2