Unigine.ObjectText Class
Inherits from: | Object |
The class is used to render flat text in a scene.
Usage Example#
Here is an example of creating ObjectText that will rotate following a player`s position, while the rotation of a parent stays the same, which will allow a parent node to move freely and drag a text with itself. To try it yourself, you should create a component named TextCreator and copy the code given below. Then assign a component to any desired node, which will be a parent node for the ObjectText.
using System;
using System.Collections;
using System.Collections.Generic;
using Unigine;
[Component(PropertyGuid = "AUTOGENERATED_GUID")] // <-- this line is generated automatically for a new component
public class TextCreator : Component
{
// Creating a parameter to define a text
public String textStr;
private ObjectText text;
private void Init()
{
// Create Object Text defining font and a string
text = new ObjectText("font.ttf", textStr);
text.FontSize = 100;
text.FontResolution = 100;
// Defining an object of a component as a parent
text.Parent = this.node;
}
private void Update()
{
// Rotate a text to always look at a player
// The pivot point will look at a player, so the text needs a little bit of tweaking
text.WorldLookAt(Game.Player.WorldPosition);
// Rotate text a little bit so it shows up properly
text.Rotate(270, 0, 180);
}
}
ObjectText Class
Properties
float TextWrapWidth#
The current text wrap width in units.
vec4 TextColor#
The color of the text.
string Text#
The text set in the node.
int DepthTest#
The A value indicating if the text object uses depth test.
int FontOutline#
The flag indicating if the text outline is enabled.
int FontVSpacing#
The vertical spacing between letters (kerning value).
int FontHSpacing#
The horizontal spacing between letters (kerning value).
int FontResolution#
The text resolution value.
int FontSize#
The text font size.
int FontRich#
The value indicating if the rich text is enabled. when enabled, tags can be used for text formatting.
string FontName#
The path to the ttf font specified in the node.
Names of font files for bold, italic and bold italic fonts must have the b, i and bi postfixes correspondingly. For example: myfontb.ttf, myfontbi.ttf.
Members
ObjectText ( ) #
Default constructor. Creates an empty object with no text and font set.ObjectText ( string font_name ) #
Constructor. Creates an object with no text but with the specified font.Arguments
- string font_name - The path to the TTF font relatively to the data directory.
ObjectText ( string font_name, string text ) #
Constructor. Creates an object with the set font and text.Arguments
- string font_name - The path to the TTF font relatively to the data directory.
- string text - The text (can be either plain or rich).
static int type ( ) #
Returns the type of the object.Return value
Object Text type identifier.Last update:
2022-12-14
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)