Game Development Reference
In-Depth Information
The sprites are clearly affected by the screen ratio, but the GUI Text position, using a percent of the
screen size, is not. If you were to enable the GUI Layer in the Camera GUI object, you would find
that the text is rendered in the exact same place for both cameras.
The first rule for using sprites is that you will have to manage your screen size. You can restrict the
player to predefined sizes, or you can adjust the Orthographic Projection Size to the screen's size
and script the camera's position to adjust accordingly. With the latter, you will probably lose the
“pixel perfect” display of the sprites. Either way, you will eventually have to do some scripting.
For setting up the sprite part of the HUD, you can set the aspect ratio or define a custom size in
the Game window. Managing sprites for different screen sizes and aspect ratios, although certainly
possible, can be quite involved. As that is a topic better covered in a fully 2D game, you will be
limiting the game's screen size in this project.
2.
In the Game view, change Free Aspect to 16:9.
3.
Adjust the battery sprites if necessary.
The view is now cropped to present the specified aspect ratio (Figure 9-26 ).
Figure 9-26. Game view constrained to 16:9
Depending on where the Main Camera is pointing, it may be possible for it to see the sprites
because they do exist in World space. So once you create a layer and a camera specifically for the
layer, you will want to tell other cameras—in this case Main Camera—not to render the sprites.
4.
Select the Main Camera, and from its Culling Mask drop-down menu,
uncheck Sprite.
Now each camera renders the appropriate objects.
Search WWH ::




Custom Search