Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Label3D

繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

用於在 3D 空間顯示純文字的節點。

說明

用於在 3D 空間顯示純文字的節點。通過調整該節點的各種屬性,可以配置文字外觀、是否面朝相機等功能。

教學

屬性

float

alpha_antialiasing_edge

0.0

AlphaAntiAliasing

alpha_antialiasing_mode

0

AlphaCutMode

alpha_cut

0

float

alpha_hash_scale

1.0

float

alpha_scissor_threshold

0.5

AutowrapMode

autowrap_mode

0

BitField[LineBreakFlag]

autowrap_trim_flags

192

BillboardMode

billboard

0

ShadowCastingSetting

cast_shadow

0 (overrides GeometryInstance3D)

bool

double_sided

true

bool

fixed_size

false

Font

font

int

font_size

32

GIMode

gi_mode

0 (overrides GeometryInstance3D)

HorizontalAlignment

horizontal_alignment

1

BitField[JustificationFlag]

justification_flags

163

String

language

""

float

line_spacing

0.0

Color

modulate

Color(1, 1, 1, 1)

bool

no_depth_test

false

Vector2

offset

Vector2(0, 0)

Color

outline_modulate

Color(0, 0, 0, 1)

int

outline_render_priority

-1

int

outline_size

12

float

pixel_size

0.005

int

render_priority

0

bool

shaded

false

StructuredTextParser

structured_text_bidi_override

0

Array

structured_text_bidi_override_options

[]

String

text

""

Direction

text_direction

0

TextureFilter

texture_filter

3

bool

uppercase

false

VerticalAlignment

vertical_alignment

1

float

width

500.0

方法

TriangleMesh

generate_triangle_mesh() const

bool

get_draw_flag(flag: DrawFlags) const

void

set_draw_flag(flag: DrawFlags, enabled: bool)


列舉

enum DrawFlags: 🔗

DrawFlags FLAG_SHADED = 0

如果打開,環境中的燈光會影響該標籤。

DrawFlags FLAG_DOUBLE_SIDED = 1

如果打開,從後面也可以看到文字。如果不打開,從後面看該文字是不可見的。

DrawFlags FLAG_DISABLE_DEPTH_TEST = 2

禁用深度測試,所以這個物件被畫在所有其他物件的上面。但是,在繪製順序中,在它之後繪製的物件可能會覆蓋它。

DrawFlags FLAG_FIXED_SIZE = 3

標籤會根據深度進行縮放,從而在螢幕上始終以相同的大小顯示。

DrawFlags FLAG_MAX = 4

代表 DrawFlags 列舉的大小。


enum AlphaCutMode: 🔗

AlphaCutMode ALPHA_CUT_DISABLED = 0

該模式會執行標準的 Alpha 混合。它可以顯示半透明區域,但當多個透明材質重疊時,可能會出現透明度排序問題。GeometryInstance3D.cast_shadow 在使用該透明模式時無效;Label3D 永遠不會投射陰影。

AlphaCutMode ALPHA_CUT_DISCARD = 1

該模式僅允許完全透明、或完全不透明的圖元。除非啟用了某種形式的螢幕空間抗鋸齒(請參閱 ProjectSettings.rendering/anti_aliasing/quality/screen_space_aa),否則會看到粗糙的邊緣。該模式也被稱為 Alpha 測試1 位透明度

注意:該模式可能會出現抗鋸齒字形和輪廓問題,請嘗試調整 alpha_scissor_threshold 或使用 MSDF 字形。

注意:當使用具有重疊字形的文字(例如草書)時,該模式可能會在正文和輪廓之間,出現透明度排序問題。

AlphaCutMode ALPHA_CUT_OPAQUE_PREPASS = 2

這個模式會在深度預處理時繪製完全不透明的圖元。比 ALPHA_CUT_DISABLEDALPHA_CUT_DISCARD 要慢,但能夠對半透明區域和平滑邊緣進行正確的排序。

注意:文字中存在重疊的字形時(例如手寫體),這個模式可能會造成主文字和輪廓的透明度排序問題。

AlphaCutMode ALPHA_CUT_HASH = 3

該模式繪製時會截斷所有低於空間確定性閾值的值,其餘值將保持不透明。


屬性說明

float alpha_antialiasing_edge = 0.0 🔗

  • void set_alpha_antialiasing_edge(value: float)

  • float get_alpha_antialiasing_edge()

在 Alpha 通道上套用抗鋸齒的臨界值。


AlphaAntiAliasing alpha_antialiasing_mode = 0 🔗

要套用的 Alpha 抗鋸齒類型。


AlphaCutMode alpha_cut = 0 🔗

The alpha cutting mode to use for the sprite.


float alpha_hash_scale = 1.0 🔗

  • void set_alpha_hash_scale(value: float)

  • float get_alpha_hash_scale()

Alpha Hash 的雜湊比例,建議值介於 02 之間。


float alpha_scissor_threshold = 0.5 🔗

  • void set_alpha_scissor_threshold(value: float)

  • float get_alpha_scissor_threshold()

Alpha 裁剪丟棄數值的閾值。


AutowrapMode autowrap_mode = 0 🔗

If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the node's bounding rectangle. If you resize the node, it will change its height automatically to show all the text.


BitField[LineBreakFlag] autowrap_trim_flags = 192 🔗

Autowrap space trimming flags. See TextServer.BREAK_TRIM_START_EDGE_SPACES and TextServer.BREAK_TRIM_END_EDGE_SPACES for more info.


BillboardMode billboard = 0 🔗

The billboard mode to use for the label.


bool double_sided = true 🔗

如果為 true,則從後面也可以看到文字,如果為 false,則從後面看它是不可見的。


bool fixed_size = false 🔗

If true, the label is rendered at the same size regardless of distance. The label's size on screen is the same as if the camera was 1.0 units away from the label's origin, regardless of the actual distance from the camera. The Camera3D's field of view (or Camera3D.size when in orthogonal/frustum mode) still affects the size the label is drawn at.


Font font 🔗

  • void set_font(value: Font)

  • Font get_font()

用於顯示文字的字形配置。


int font_size = 32 🔗

  • void set_font_size(value: int)

  • int get_font_size()

Label3D 文字的字形大小。為了讓字形在近距離時看起來更細膩,可增加 font_size,同時減小 pixel_size

較大的字形大小需要更多時間來算繪新字元,這可能會導致在遊戲過程中卡頓。


HorizontalAlignment horizontal_alignment = 1 🔗

Controls the text's horizontal alignment. Supports left, center, right, and fill (also known as justify).


BitField[JustificationFlag] justification_flags = 163 🔗

Line fill alignment rules.


String language = "" 🔗

Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.


float line_spacing = 0.0 🔗

  • void set_line_spacing(value: float)

  • float get_line_spacing()

Additional vertical spacing between lines (in pixels), spacing is added to line descent. This value can be negative.


Color modulate = Color(1, 1, 1, 1) 🔗

  • void set_modulate(value: Color)

  • Color get_modulate()

Label3D 的文字顏色 Color


bool no_depth_test = false 🔗

若設為 true,將停用深度測試,物件依繪製順序顯示。


Vector2 offset = Vector2(0, 0) 🔗

文字繪製偏移(單位為圖元)。


Color outline_modulate = Color(0, 0, 0, 1) 🔗

  • void set_outline_modulate(value: Color)

  • Color get_outline_modulate()

文字輪廓的色調。


int outline_render_priority = -1 🔗

  • void set_outline_render_priority(value: int)

  • int get_outline_render_priority()

設定文字輪廓的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。

注意:僅在 alpha_cutALPHA_CUT_DISABLED(預設值)時適用。

注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。


int outline_size = 12 🔗

  • void set_outline_size(value: int)

  • int get_outline_size()

文字輪廓大小。


float pixel_size = 0.005 🔗

  • void set_pixel_size(value: float)

  • float get_pixel_size()

標籤中一個圖元寬度對應縮放至的 3D 大小。要讓字形在較近距離時也能夠看到細節,請在減小 pixel_size 的同時增大 font_size


int render_priority = 0 🔗

  • void set_render_priority(value: int)

  • int get_render_priority()

設定文字的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。

注意:僅在 alpha_cutALPHA_CUT_DISABLED(預設值)時適用。

注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。


bool shaded = false 🔗

如果為 true,則 Environment 中的 Light3D 會影響該標籤。


StructuredTextParser structured_text_bidi_override = 0 🔗

為結構化文字設定 BiDi 演算法覆蓋。


Array structured_text_bidi_override_options = [] 🔗

  • void set_structured_text_bidi_override_options(value: Array)

  • Array get_structured_text_bidi_override_options()

設定 BiDi 覆蓋的附加選項。


String text = "" 🔗

要在螢幕上顯示的文字。


Direction text_direction = 0 🔗

基礎文字書寫方向。


TextureFilter texture_filter = 3 🔗

Filter flags for the texture.


bool uppercase = false 🔗

  • void set_uppercase(value: bool)

  • bool is_uppercase()

如果為 true,所有文字都將顯示為大寫。


VerticalAlignment vertical_alignment = 1 🔗

Controls the text's vertical alignment. Supports top, center, and bottom.


float width = 500.0 🔗

文字寬度(單位為圖元),用於自動換行和填充對齊。


方法說明

TriangleMesh generate_triangle_mesh() const 🔗

返回使用該標籤的頂點組成的 TriangleMesh,遵循目前的配置(例如 pixel_size)。


bool get_draw_flag(flag: DrawFlags) const 🔗

返回指定旗標的值。


void set_draw_flag(flag: DrawFlags, enabled: bool) 🔗

If true, the specified flag will be enabled.