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

Widget parameters


You can see more parameters below the Color Tint field. These are the widget's global parameters from the UIWidget class—they are common to most NGUI widget components, such as UILabel, UISprite, and UIScrollbar, since they are derived from it:

  1. Pivot: This is the widget's pivot point. This represents the static point from which the widget will resize itself:

    • Left set of buttons: Horizontal pivot point

    • Right set of buttons: Vertical pivot point

    Note

    As you change the pivot point using the sets of buttons, its Transform position updates relatively to maintain its current world position.

  2. Depth: Change this value to render a widget over another. The widget with the highest value is rendered on top. You can use the Back and Forward buttons or simply enter a number. Negative values are accepted.

    Note

    If you need a widget over another, make sure they don't have the same Depth value; you might not have the one you want rendered over the other.

  3. Size: This shows the widget's dimensions in pixels. It is grayed out here because the label's Overflow parameter is set to ResizeFreely and is automatic.

    Tip

    You should use the Size(3) parameter and keep the widget's scale at (1, 1, 1) if you want to keep your UI pixel-perfect and avoid bad surprises!

  4. Aspect: Select any of the following desired aspect ratio lock behaviors:

    • Free: You are free to modify the widget's height and width as you wish—no aspect ratio is imposed

    • BasedOnWidth: You are free to modify the width only—the height will adjust automatically to keep the current aspect ratio

    • BasedOnHeight: You are free to modify the widget's height only—the width will adjust to keep the current aspect ratio

Below these parameters, you can see the Anchors group. We'll deal with them later since we need to have more widgets to really understand how they work.

We can now see how to display images!