Version: 2018.4
Legacy GUI
GUI Texture (Legacy UI Component)

GUI Text (Legacy UI Component)

Switch to Scripting

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

Please Note: This component relates to legacy methods for drawing UI(User Interface) Allows a user to interact with your application. More info
See in Glossary
textures and images to the screen. You should use Unity’s up-to-date UI system instead. This is also unrelated to the IMGUI system.

Properties

Property: Function:
TextA non-interactive piece of text to the user. This can be used to provide captions or labels for other GUI controls or to display instructions or other text. More info
See in Glossary
The string to display.
AnchorA UI layout tool that fixes a UI element to a parent element. Anchors are shown as four small triangular handles in the Scene View and anchor information is also shown in the Inspector. More info
See in Glossary
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 renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
the text.
MaterialAn asset that defines how a surface should be rendered, by including references to the Textures it uses, tiling information, Color tints and more. The available options for a Material depend on which Shader the Material is using. More info
See in Glossary
Reference to the Material containing the characters to be drawn. If set, this property overrides the one in the Font assetAny media or data that can be used in your game or Project. An asset may come from a file created outside of Unity, such as a 3D model, an audio file or an image. You can also create some asset types in Unity, such as an Animator Controller, an Audio Mixer or a Render Texture. More info
See in Glossary
.
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 CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary
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 add a GUIText component in Unity 5.0, first use GameObject->Create Empty to create an empty game object, then use the Component->Rendering->GUIText option to add the GUIText component to the newly created game object. If the text isn’t visible when you press Play, check that the transform has suitable position, typically (0.5, 0.5, 0.0).

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 pixelsThe smallest unit in a computer image. Pixel size depends on your screen resolution. Pixel lighting is calculated at every screen pixel. More info
See in Glossary
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).
Legacy GUI
GUI Texture (Legacy UI Component)
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961