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.
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:
Assets/Resources/Fonts
folder.SmallLato 1
to ScreenFont
.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:
Good! Now, we should use ScreenFont
instead of any other when we configure our label widgets. We have just configured it so that it points to the MediumLato
font by default. We can now assign it to a new label.
We have created our reference ScreenFont
. We can now create a new label using it:
UI Root
GameObject.0
, -280
, 0
}.UI Root
| Label
to SmallText2
, and then:Paragraph Heading
Now, let's make sure that all labels except LargeText
use new ScreenFont
:
UI Root
| SmallText
and MediumText
GameObjects.Now, all labels except the LargeText
label are using ScreenFont
, which currently points to the MediumLato
font. Let's change the LargeText
label to use the Coalition
font:
UI Root
| LargeText
GameObject.Good. Now, your Game view should look like this:
The
ScreenFont
reference font assigned to the preceding labels 2, 3, and 4 allows us to change their font in only one simple step. Let's try it now:
Assets/Resources/Fonts/ScreenFont
prefab.UIFont
component:And that's it! By changing the pointed font for the ScreenFont
reference font, we have now changed the used font for all labels with ScreenFont
assigned.
You should now have all labels, except LargeText
, using the SciFi Font – Normal font as shown in the following screenshot:
Great! Now, let's summarize what you've learned in this chapter.
3.15.231.194