This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
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
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

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

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

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
Build: ()