Legacy Documentation: Version 4.6
Language: English
GUI Style (Legacy)
GUI Texture (Legacy)

GUI Text (Legacy)

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Scripting

GUI Text displays text of any font you import in screen coordinates.

Please Note: Unity 2.0 introduced UnityGUI, a GUI Scripting system. You may prefer creating user interface elements with UnityGUI instead of GUI Texts. Read more about how to use UnityGUI in the GUI Scripting Guide.

Properties

Property: Function:
Text The string to display.
Anchor The point at which the Text shares the position of the Transform.
Alignment How multiple lines are aligned within the GUIText.
Pixel Offset Offset of the text relative to the position of the GUIText in the screen.
Line Spacing How much space will be in-between lines of Text.
Tab Size How much space will be inserted for a tab (‘\t’) character. As a multiplum of the space character offset.
Font The Font to use when rendering the text.
Material Reference to the Material containing the characters to be drawn. If set, this property overrides the one in the Font asset.
Font Size The font size to use. Set to 0 to use the default font size. Only applicable for dynamic fonts.
Font Style The font style to use. (Normal, Bold, Italic or Bold and Italic). Only applicable for dynamic fonts.
Pixel Correct If enabled, all Text characters will be drawn in the size of the imported font texture. If disabled, the characters will be resized based on the Transform’s Scale.
Rich Text If enabled, allows HTML-style tags for text formatting.

Details

GUI Texts are used to print text onto the screen in 2D. The Camera has to have a GUI Layer attached in order to render the text. Cameras include a GUI Layer by default, so don’t remove it if you want to display a GUI Text. GUI Texts are positioned using only the X and Y axes. Rather than being positioned in World Coordinates, GUI Texts are positioned in Screen Coordinates, where (0,0) is the bottom-left and (1,1) is the top-right corner of the screen

To import a font see the Font page.

To use Rich Text see the Rich Text page.

Pixel Correct

By default, GUI Texts are rendered with Pixel Correct enabled. This makes them look crisp and they will stay the same size in pixels independent of the screen resolution.

Hints

  • When entering text into the Text property, you can create a line break by holding Alt and pressing Return.
  • If you are scripting the Text property, you can add line breaks by inserting the escape character “\n” in your strings.
  • You can download free true type fonts from 1001freefonts.com (download the Windows fonts since they contain TrueType fonts).
GUI Style (Legacy)
GUI Texture (Legacy)