This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
Tutorials

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