用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:textgenerator:textgenerator

TextGenerator 文本生成器

Namespace: UnityEngine

Description 描述

Class that can be used to generate text for rendering.
此类可以用于生成用于渲染的文本。

Caches vertices, character info, and line info for memory friendlyness.
缓存内存友好的顶点,字符信息和行信息。

JavaScript

var font : Font;
function Start () {
	var settings = new TextGenerationSettings();
	settings.anchor = TextAnchor.MiddleCenter; 
	settings.color = Color.red; 
	settings.extents = new Vector2(500f, 200f); 
	settings.pivot = Vector2.zero; 
	settings.richText = true; 
	settings.font = font; 
	settings.size = 32; 
	settings.style = FontStyle.Normal; 
	settings.wrapMode = TextWrapMode.Wrap;
 
	var generator = new TextGenerator();
	generator.Populate("I am a string", settings);
	Debug.Log("I generated: " + generator.vertexCount + " verts!"); 
}

C#

using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
    public Font font;
    void Start() {
        TextGenerationSettings settings = new TextGenerationSettings();
        settings.anchor = TextAnchor.MiddleCenter;
        settings.color = Color.red;
        settings.extents = new Vector2(500.0F, 200.0F);
        settings.pivot = Vector2.zero;
        settings.richText = true;
        settings.font = font;
        settings.size = 32;
        settings.style = FontStyle.Normal;
        settings.wrapMode = TextWrapMode.Wrap;
        TextGenerator generator = new TextGenerator();
        generator.Populate("I am a string", settings);
        Debug.Log("I generated: " + generator.vertexCount + " verts!");
    }
}

Variables 变量

characterCount The number of characters that have been generated.
生成的字符的数量。
characters Array of generated characters.
生成的字符的数组。
extents Extends of generated text area.
生成的文本区域的长度。
lineCount Number of text lines generated.
生成的行数量。
script/unityengine/classes/textgenerator/textgenerator.txt · 最后更改: 2016/08/02 05:28 (外部编辑)