Game Development Reference
In-Depth Information
You will notice I didn't delve into Anchors for the World Space
Canvas. They aren't as important with World Space UI due to them
being rendered in 3D; however, I would recommend that you use
them where possible to ensure you keep in the habit of using them.
A final word on Event Cameras
Now, as the previous UI didn't have any interactive elements on it, we didn't bother
setting up an Event Camera for the World Space Canvas. You only need to apply an
Event Camera if you want to alter the rendering of a World Space Canvas and thus
need to specify a different camera to do the raycasting for the UI input.
The Unity examples ( http://bit.ly/UnityOfficialUIExamples ) already do a
good job of demonstrating this, and in most cases for World Space UI, you will not
need to define a separate Event Camera .
Remember, if you don't specify an Event Camera , it will use the Main
Camera by default.
If you don't have any buttons, sliders, or other interactive elements,
there isn't much point setting one.
So, either the UI will be in the main view and use the Main Camera , or you will
need to draw it in a particular part of the screen (say an Inventory UI). In this case,
you will use a separate camera (like what was done with the Screen Space - Camera
examples earlier), which will be used as the Event Camera and help you to provide
direct (simplify) input and render the World Space UI.
Summary
This chapter has been the most fun and I could have really run away with it,
showing a lot more examples using these two canvas modes, but where's the fun if I
do it all for you? Go create! Think up weird and wacky ideas that are not just flat or
information; throw stuff in your game world like never before and go wild.
The Unity 5 preview presentation on UI ( http://bit.ly/U5Preview at about
the 1-minute mark) showed some other excellent examples of using these Canvas
modes, including using a World Space Canvas attached to a block that pops up a
conversation window aligned to the object in the game (not the player as I've shown
here). The UI system it shows is actually from 4.6 that has been ported to U5, so
everything you see is possible today.
 
Search WWH ::




Custom Search