Customizing the MainMenu

The blue background of our menu's main camera is not very nice. Let's set a black background for the camera, and add our space tiling sprite to make this better:

  1. Select our MainMenu GameObject from Anchor, and create a new sprite by navigating to NGUI | Create | Sprite, or press Alt + Shift + S.
  2. Select the new Sprite GameObject from MainMenu and perform the following steps:
    1. Rename it as Space.
    2. Set its Atlas type to our Game atlas.
    3. Set its Sprite to our Space tiling sprite.
    4. Set its Sprite Type parameter to Tiled.
  3. Attach a Stretch component to it by navigating to Component | NGUI | UI:
  4. Set its Style parameter to Both.

You may notice that we have ugly lines between each repetition of the Space sprite. That is simply because there is a 1-pixel-wide border on the sprite. We can easily correct this by reducing the sprite's border value of 1 pixel.

Select our Space GameObject from MainMenu, and click on the Edit button next to the Sprite field, as shown in the following screenshot:

Customizing the MainMenu

Set a value of 1 for each of the four Border parameters as shown in the following screenshot:

Customizing the MainMenu

That's better; our tiling sprite now tiles correctly without any lines between each pattern.

Now that you have learned how to add sprites and fonts, I would like you to change our Main Menu elements' backgrounds to make it look better. You may proceed as you wish—add more sprites if you want, change colors, and use your imagination!

The following is an example of what you can achieve with the Window and Button sprites:

Customizing the MainMenu

Note

You might have to move or resize the UI elements. Don't forget to use Pixel Offset in UIAnchor to move or resize instead of positions. Same for Dimensions—don't use the scale tool of Unity if you want to keep the widgets pixel perfect.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.171.107