Game Development Reference
In-Depth Information
Step 4: In the Scene window, move the Main Camera in the scene so that
(in the Game window) Aegis appears on the side with room for the GUI on
the right side of the screen.
Step 5: Create a GUITexture GameObject. Choose GameObject>Create
Other>GUI Texture. A new GameObject will appear in the Hierarchy panel
called UnityWatermark-small (or possibly New Texture, depending on your
system setup). You will also likely see a Unity logo appear in the middle
of both the Scene and Game windows. This is the GUITexture that Unity
automatically and narcissistically assigns its own logo to.
Step 6: Assign the Incursion_Logo texture to the GUITexture. Do this by
either dragging the Incursion_Logo texture from the 2D Assets folder in
the Project panel to the Texture input field of the GUITexture component
in the Inspector, or by using the target icon button next to the Texture
(of the GUITexture component) input field.
Step 7: Resize the texture. Do this in the Inspector under the GUITexture
component.ExpandthePixelInsetsectionandchangetheWidthto512
andtheHeightto128(orsmallerifneedbeonyourmonitor).
Tips and Tricks
Defining the Width and Height defines the absolute size of the GUITexture
onthescreen.Althoughtheimagewasbuiltatmuchlarger(1024×256),
upon placement it just seemed too big. But because we can define the
absolute size in the GUITexture component, the original size doesn't carry
a huge importance. Do keep in mind though that if the Width and Height
are set larger than the original image, there is always some degradation
of quality, and sometimes it's just worth it to go back into Photoshop and
rebuild the image at a more appropriate size.
Step 8: PositionthelogobychangingtheTransformX=0.5,theTransform
Y = 1, and changing the Pixel Inset X = 0 and Y = -200. All of this of course
is done in the Inspector ( Figure 12.2 ).
Why?
Step7resizedthetexturewhilestep8getsitintherightspot.Theway
that GUITextures work can be a little confusing. Notice that by default
theTransformcomponentfortheNewTextureobjectissetupwithX=0.5
andY=0.5(notethatthesearenotthePixelInsetvalues,theyarethe
Transform values); this is the center of the screen. What's happening here
isUnitylooksatthetotalsizeofthescreenanddefinesitat1×1.X=0
and Y = 0 is the bottom-left corner of the screen while X = 1 and Y = 1
is the top right. Unity takes the bottom-left corner of the GUITexture, and
places it at the Transform Position coordinates, then offsets the image
according to the Pixel Inset section of the GUITexture component.
So, since Unity thinks of the image's axis point as the bottom left if the Pixel
Inset X and Y are both set to 0, and the Transform's X and Y are both at 0, the
 
Search WWH ::




Custom Search