This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Режимы вывода изображения
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
API Samples
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

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.

TextCreator.cs
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

string Text#

The text set in the node.

vec4 TextColor#

The color of the text.

float TextWrapWidth#

The text wrap width in units. The text will wrap if its physical size will be greater than the set value.

int DepthTest#

The 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). This parameter influences the text's physical size.

int FontHSpacing#

The horizontal spacing between letters (kerning value). This parameter influences the text's physical size.

int FontResolution#

The resolution of the texture into which the text will be rendered. The lower the value, the less detailed will be the text, the less video memory will be required for the texture. It doesn't influence the text's physical size.

int FontSize#

The size of the text font. The more dots, the higher the size of the font. To match dots with a 3D space, there is a set value: 288 dots per unit. For example, if you have the Arial font with the size of 20, the physical height of the letter can be calculated as 20/288=0.0694 units.

int FontRich#

The flag indicating if the rich text is enabled. When enabled, the following tags can be used for text formatting:
  • <b>text</b> specifies a bold text.
  • <i>text</i> specifies an italic text.
  • <br>text<br/> inserts a single line break.
  • <left>text</left> left-aligns the text.
  • <right>text</right> right-aligns the text.
  • <center>text</center> center-aligns the text.
  • <p align=left|right|center|justify>text</p> specifies the alignment of the text within a paragraph:
    • left - left-aligns the text
    • right - right-aligns the text
    • center - center-aligns the text
    • justify - stretches the lines so that each line has equal width (like in newspapers and magazines)
    Notice
    Text alignment requires text wrapping to be enabled: the value of the Wrap Width parameter must be greater than 0.
  • <font size=12 color=magenta face=verdana> text</font> specifies the font face, font size, and color of text.
  • <sub> text</sub> defines subscript text. Subscript text appears half a character below the normal line, and is sometimes rendered in a smaller font.
  • <sup> text</sup> defines superscript text. Superscript text appears half a character above the normal line, and is sometimes rendered in a smaller font.
Notice
<image/> and <table/> tags are not available.

string FontName#

The path to the TTF font.
Notice
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.

float TextWidth#

The width of the text.

float TextHeight#

The height of the text.

float TextAspect#

The text aspect value, the proportional relationship between the text width and height.

int TextNumLines#

The number of lines in the text.

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).
Last update: 13.12.2024
Build: ()