Game Development Reference
In-Depth Information
First, we set the parameters for the Border . These parameters will offset the pixels of the
current UI graphics from 0 to the number that we assigned. For example, if we want to draw
a rectangular window, which is 320 pixels in width and 240 pixels in height, and we set the
Left Border to 27, Right to 27, Top to 55, and Bottom to 96, this will tell Unity GUIStyle to
always draw the graphics from pixel 0 to pixel 27 on the left side with the same scale as the
source texture. What will happen from pixel 28? Basically, it will repeat pixel 27 unil it hits
the right Border , which is also set to 27 pixels from the right. So, this means that we tell the
GUIStyle to draw graphics from the source texture from pixel 0 to pixel 27, and repeat the
texture from pixel 28 to pixel 293, then switch back and draw pixel 294 to pixel 320 from the
source texture, which is the offset of 27 pixels from the right. This also applies to the top and
botom Borders , as we can see on the left side of the preceding figure.
From this concept, we can save a lot of memory because instead of using a 320 x 240 pixel
image, we just use 54 x 151 pixels. However, in some cases we don't want any repeaing
pixels for our UI such as ixed buton graphics—for example, our Exit Button style—or any
fixed texture, and so on, as we can see in the following figure:
 
Search WWH ::




Custom Search