< Return to Video

UI Text - Unity Official Tutorials

  • 0:00 - 0:02
    The text component is used to render text
  • 0:02 - 0:05
    on the screen as part of your UI layouts.
  • 0:05 - 0:07
    The primary property of a text component
  • 0:07 - 0:08
    is it's text.
  • 0:08 - 0:11
    This is the string that will be shown on screen.
  • 0:11 - 0:13
    It can be used as a simple label,
  • 0:13 - 0:16
    or dynamically to show things like scores for example.
  • 0:24 - 0:26
    One thing to note is that return works within
  • 0:26 - 0:28
    this text field to create new lines.
  • 0:28 - 0:30
    So be aware of this, as well as the possibility
  • 0:30 - 0:32
    of leaving new empty lines.
  • 0:34 - 0:36
    The Character section of the component defines
  • 0:36 - 0:38
    how the characters of the string will look.
  • 0:38 - 0:40
    The Font is the font asset used for this
  • 0:40 - 0:42
    particular component.
  • 0:42 - 0:46
    Unity supports TrueType, OpenType and Dafont typefaces.
  • 0:46 - 0:48
    But remember that unlike most software
  • 0:48 - 0:50
    because Unity is authoring an external
  • 0:50 - 0:52
    game or application, your font must be included
  • 0:52 - 0:55
    in your project's assets in order to be used.
  • 0:55 - 0:58
    The style can either be normal, bold or italic,
  • 0:58 - 0:59
    or bold and italic.
  • 0:59 - 1:01
    And the font size will be the font size
  • 1:01 - 1:02
    that it's forced to.
  • 1:02 - 1:05
    If the font size is too large to fit within the rect
  • 1:05 - 1:07
    then the text will not be displayed
  • 1:07 - 1:09
    unless overflow settings are used.
  • 1:18 - 1:20
    Line spacing is also available to aid
  • 1:20 - 1:23
    legibility within paragraphs of text.
  • 1:28 - 1:30
    The Rich Text checkbox allows the use
  • 1:30 - 1:33
    of text markup, which allows you to use tags
  • 1:33 - 1:34
    in-line to format text
  • 1:34 - 1:36
    in a similar way to HTML.
  • 1:37 - 1:40
    For more details on text markup and how to use it
  • 1:40 - 1:42
    see the documentation links below.
  • 1:42 - 1:44
    The Paragraph section defines how text
  • 1:44 - 1:45
    will sit within it's rect.
  • 1:45 - 1:48
    Text can be aligned left, centre or right,
  • 1:48 - 1:49
    top, middle or bottom.
  • 1:49 - 1:52
    Though in this example we cannot see top, middle or bottom
  • 1:52 - 1:55
    alignment due to the scrollable nature of the box.
  • 1:55 - 1:57
    Horizontal Overflow controls what will happen
  • 1:57 - 2:00
    to the text that exceeds beyond it's horizontal limit.
  • 2:00 - 2:04
    Wrap will move any text beyond the limit to the next line.
  • 2:04 - 2:06
    Whereas Overflow will allow the text to extend
  • 2:06 - 2:08
    beyond the horizontal bounds of the rect.
  • 2:08 - 2:11
    Vertical Overflow is similar, but works vertically.
  • 2:11 - 2:14
    Truncate means that any text beyond the vertical
  • 2:14 - 2:15
    bounds of the rect will be cut.
  • 2:15 - 2:17
    Overflow will allow the text to go beyond the
  • 2:17 - 2:19
    vertical limits of the rect.
  • 2:19 - 2:22
    When Best Fit is checked, the text will ignore the
  • 2:22 - 2:25
    overflow options and instead make text as large
  • 2:25 - 2:27
    or as small as necessary to fit within
  • 2:27 - 2:28
    the available rect.
  • 2:28 - 2:31
    The Min and Max size properties refer to
  • 2:31 - 2:32
    the limits of the font size.
  • 2:32 - 2:34
    When a best fit would mean having text that was
  • 2:34 - 2:36
    beyond either of these font size limits
  • 2:36 - 2:39
    the text will obey the normal font size provided.
  • 2:40 - 2:42
    The appearance of characters of text can be
  • 2:42 - 2:45
    adjusted by using the Color and Material properties.
  • 2:45 - 2:47
    Generally, a texture of a material will
  • 2:47 - 2:50
    not effect the appearance of text that it's supplied to.
  • 2:50 - 2:52
    Let's take a quick look at the text component
  • 2:52 - 2:53
    in use dynamically.
  • 2:53 - 2:56
    Very simply, this text element represents the
  • 2:56 - 2:57
    score in this game.
  • 2:57 - 3:00
    By default we've written in an example line.
  • 3:00 - 3:03
    But this is only for design purposes
  • 3:03 - 3:05
    as it's replaced at runtime by the
  • 3:05 - 3:07
    string defined within our script
  • 3:07 - 3:09
    which sets the score dynamically
  • 3:09 - 3:11
    as the player scores points.
  • 3:18 - 3:20
    For more information on the text component
  • 3:20 - 3:22
    and using text dynamically
  • 3:22 - 3:24
    please see the information linked below.
Title:
UI Text - Unity Official Tutorials
Description:

more » « less
Video Language:
English
Duration:
03:25

English subtitles

Revisions