返回介绍

Font.RequestCharactersInTexture 请求字符纹理

发布于 2019-12-18 15:37:41 字数 2490 浏览 1788 评论 0 收藏 0

JavaScript => public function RequestCharactersInTexture(characters: string, size: int = 0, style: FontStyle = FontStyle.Normal): void;
C# => public void RequestCharactersInTexture(string characters, int size = 0, FontStyle style = FontStyle.Normal);

Parameters 参数

charactersThe characters which are needed to be in the font texture.
sizeThe size of the requested characters (the default value of zero will use the font's default size).
styleThe style of the requested characters.

Description 描述

Request characters to be added to the font texture (dynamic fonts only).

请求字符被加入到字体纹理中(仅限动态字体)。

Note: You should only ever need to use this when you want to implement your own text rendering. Call this function to request Unity to make sure all the characters in the string characters are available in the font's font texture (and it's characterInfo property). This is useful when you want to implement your own code to render dynamic fonts. You can supply a custom font size and style for the characters. If size is zero (the default), it will use the default size for that font.

注意:当你想要实现自定义的文本渲染时你只需要使用该函数。调用该函数请求Unity确保在字体的字体纹理中(和它的字符信息属性)所有字符串字符是可获取的。当你想要实现代码渲染动态字体,该函数是有用的。你可以提供一个自定义字体大小和类型的字符。如果字体大小为0(默认),该字体将会使用默认大小。

RequestCharactersInTexture may cause the font texture to be regenerated if it does not have space to add all the requested characters. If the font texture is regenerated it will only contain characters which have been used using Font.RequestCharactersInTexture, or using Unity's text rendering functions during the last frame. So it is advisable to always call RequestCharactersInTexture for any text on the screen you wish to render using custom font rendering functions, even if the characters are currently present in the texture, to make sure they don't get purged during texture rebuild.

如果没有空间添加所有要求字符,RequestCharactersInTexture 可能导致字体纹理再生。如果该字体纹理再生,它将仅包含曾使用的字体字符信息,或者在最后帧中unity的文本渲染的功能。因此建议在屏幕上的任何你想要渲染的字体总是调用RequestCharactersInTexture,使用自定义文本渲染功能,甚至在当前文本中的字符,确保在纹理重建期间不要清除当前文本。

See Also: textureRebuilt, GetCharacterInfo.

font

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文