Unity 2018 Cookbook(Third Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

To display a text message with sophisticated TextMeshPro visual styling, follow these steps:

  1. Create a new Unity 3D project.
  1. Add a new UI TextMeshPro Text GameObject in the scene  choose menu:
    GameObject | UI | TextMeshPro  text. Name this GameObject Text-sophisticated.
TextMeshPro GameObjects do not have to be part of the UI Canvas. You can add a TextMeshPro GameObject to the Scene directly by choosing the Scene panel menu Create | 3D Object | TextMeshPro  text.
  1. Ensure that your new Text-sophisticated GameObject is selected in the Hierarchy panel. In the Inspector for the Rect Transform, click on the Anchor Presets square icon, hold down Shift + Alt, and click on the top and stretch rows.
  2. Ensure the following properties are set:
    Font Settings:
    • Font Asset set to Anton SDF
    • Material Preset set to Anton SDF - Outline
    • Font size 200
    • Alignment set to horizontal center
  3. Face:
    • Color set to white
    • Dilate set to 0
  4. Outline:
    • Color set to Red
    • Thickness set to 0.1
  5. Underlay (shadow):
    • Offset X set to 1
    • Offset Y set to -1
    • Dilate set to 1

The following screenshot shows the Inspector panel with these settings:

  1. The Text-sophisticated GameObject will now appear as very large, with a white inner, red outline, and a drop shadow to the lower right.