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

Switching fonts


We have set up a system to switch atlases at runtime depending on the screen's size. We can also use reference fonts to make sure we can easily switch multiple labels' fonts in one click.

ScreenFont

We will now create a fourth font, which will be a reference font, pointing to another one. We'll use it to change the font used for all labels very easily:

  1. In the Project view, go to the Assets/Resources/Fonts folder.

  2. Select the SmallLato font prefab file, as follows:

  3. Duplicate it with Ctrl + D.

  4. Rename the new duplicate from SmallLato 1 to ScreenFont.

  5. Select our new ScreenFont prefab file.

The Inspector view displays the following content:

The ScreenFont prefab's Font Type (1) is currently set to Bitmap. Switch it to Reference now. The Inspector panel now looks like this:

You might notice that all the font information has disappeared; this reference font currently points to nothing. Let's make it point to the MediumLato font by default:

  1. Click on the Font button (1).

  2. Select the MediumLato...