Game Development Reference
In-Depth Information
If you recall, in Chapter 2 , Building Layouts , we determined where the mouse was and
where the user clicked on or touched the screen by casting a ray (pointer) from the
camera. It then passed through the scene in the direction the camera is facing until it
hit either a UI element or passed straight through. This information was then passed
back to the UI EventSystem for processing.
In most cases, you may want to just use the default ( Main Camera ).
If, however, you are rendering your UI on a different camera, be
sure to set it as the Event Camera or none of your input will work.
Getting some perspective
As we start to look deeper into the Screen Space - Camera Canvas , we will see a
world of opportunity to enrich our boring, flat UI (although I quite like a flat UI for
many things) and make it a little more engaging.
As we delve into this, we'll first look at some very simple examples before jumping
into our main demo scene in 3D.
If you haven't started your project in 3D mode , then it might be worth
starting a new project for this chapter in 3D mode .
It's not essential but will makes things a little easier.
As an example, we can work with the Field of View of our Render Camera to draw
our UI out of the screen:
1.
Create a Canvas and set the Render Mode to Screen Space - Camera .
2.
Add a new Camera ( Layer = UI , Clear Flags = Don't Clear , and Field of
View = 1 ) and name it UICamera .
3.
Set the Canvas Render Camera to the new UICamera.
4.
Add an Image with a Button on top of it (Button as a child of the Image).
5.
Set each element transform's Pos Z value closer to the camera (Image 0,
Button -10, and Text -20).
6.
Now select the UICamera and switch to the Game view. Altering the Field
Of View will now draw out each layer of the UI from the screen.
 
Search WWH ::




Custom Search