Book Image

Learning NGUI for Unity

By : Charles Bernardoff (EURO)
Book Image

Learning NGUI for Unity

By: Charles Bernardoff (EURO)

Overview of this book

Table of Contents (17 chapters)
Learning NGUI for Unity
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The 3D environment text


We can also add 3D widgets directly within the environment, as shown:

In order achieve this, we must create an empty GameObject as a child of the Ground GameObject, which has the UIPanel component attached to it for widget rendering.

After this, we can create our widget, place it at the desired location, and make sure it lies in the default environment camera layer instead of the usual UI layer.

Let's try it now:

  1. Select our Ground GameObject.

  2. Create a new empty child GameObject pressing Alt + Shift + N and select it:

    • Rename this new child to LevelName.

    • Set its Transform position to {0, 0, -3.8}.

  3. Click on the Add Component button in the inspector.

  4. Type in panel to search for components with this name.

  5. Select NGUI Panel and hit Enter.

  6. Create a new child sprite by pressing Alt + Shift + S.

    • Rename this new sprite to Background.

    • Set Atlas to Wooden Atlas.

    • Change Sprite to the Flat sprite.

    • Make sure Type is set to Sliced.

    • Set Size to 360 x 100.

As you can see in the following screenshot...