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.
Checking the stable version of the documentation...
Label3D
繼承: GeometryInstance3D < VisualInstance3D < Node3D < Node < Object
用於在 3D 空間顯示純文字的節點。
說明
用於在 3D 空間顯示純文字的節點。通過調整該節點的各種屬性,可以配置文字外觀、是否面朝相機等功能。
教學
屬性
|
||
|
||
|
||
|
||
|
||
|
||
BitField[LineBreakFlag] |
|
|
|
||
cast_shadow |
|
|
|
||
|
||
|
||
gi_mode |
|
|
|
||
BitField[JustificationFlag] |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
generate_triangle_mesh() const |
|
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_DISABLED 或 ALPHA_CUT_DISCARD 要慢,但能夠對半透明區域和平滑邊緣進行正確的排序。
注意:文字中存在重疊的字形時(例如手寫體),這個模式可能會造成主文字和輪廓的透明度排序問題。
AlphaCutMode ALPHA_CUT_HASH = 3
該模式繪製時會截斷所有低於空間確定性閾值的值,其餘值將保持不透明。
屬性說明
float alpha_antialiasing_edge = 0.0 🔗
在 Alpha 通道上套用抗鋸齒的臨界值。
AlphaAntiAliasing alpha_antialiasing_mode = 0 🔗
void set_alpha_antialiasing(value: AlphaAntiAliasing)
AlphaAntiAliasing get_alpha_antialiasing()
要套用的 Alpha 抗鋸齒類型。
AlphaCutMode alpha_cut = 0 🔗
void set_alpha_cut_mode(value: AlphaCutMode)
AlphaCutMode get_alpha_cut_mode()
The alpha cutting mode to use for the sprite.
float alpha_hash_scale = 1.0 🔗
Alpha Hash 的雜湊比例,建議值介於 0 與 2 之間。
float alpha_scissor_threshold = 0.5 🔗
Alpha 裁剪丟棄數值的閾值。
AutowrapMode autowrap_mode = 0 🔗
void set_autowrap_mode(value: AutowrapMode)
AutowrapMode get_autowrap_mode()
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 🔗
void set_autowrap_trim_flags(value: BitField[LineBreakFlag])
BitField[LineBreakFlag] get_autowrap_trim_flags()
Autowrap space trimming flags. See TextServer.BREAK_TRIM_START_EDGE_SPACES and TextServer.BREAK_TRIM_END_EDGE_SPACES for more info.
BillboardMode billboard = 0 🔗
void set_billboard_mode(value: BillboardMode)
BillboardMode get_billboard_mode()
The billboard mode to use for the label.
如果為 true,則從後面也可以看到文字,如果為 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.
用於顯示文字的字形配置。
Label3D 文字的字形大小。為了讓字形在近距離時看起來更細膩,可增加 font_size,同時減小 pixel_size。
較大的字形大小需要更多時間來算繪新字元,這可能會導致在遊戲過程中卡頓。
HorizontalAlignment horizontal_alignment = 1 🔗
void set_horizontal_alignment(value: HorizontalAlignment)
HorizontalAlignment get_horizontal_alignment()
Controls the text's horizontal alignment. Supports left, center, right, and fill (also known as justify).
BitField[JustificationFlag] justification_flags = 163 🔗
void set_justification_flags(value: BitField[JustificationFlag])
BitField[JustificationFlag] get_justification_flags()
Line fill alignment rules.
Language code used for line-breaking and text shaping algorithms. If left empty, the current locale is used instead.
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) 🔗
該 Label3D 的文字顏色 Color。
若設為 true,將停用深度測試,物件依繪製順序顯示。
Vector2 offset = Vector2(0, 0) 🔗
文字繪製偏移(單位為圖元)。
Color outline_modulate = Color(0, 0, 0, 1) 🔗
文字輪廓的色調。
int outline_render_priority = -1 🔗
設定文字輪廓的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。
注意:僅在 alpha_cut 為 ALPHA_CUT_DISABLED(預設值)時適用。
注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。
文字輪廓大小。
標籤中一個圖元寬度對應縮放至的 3D 大小。要讓字形在較近距離時也能夠看到細節,請在減小 pixel_size 的同時增大 font_size。
設定文字的算繪優先順序。優先順序高的物體將被排序在優先順序低的物體前面。
注意:僅在 alpha_cut 為 ALPHA_CUT_DISABLED(預設值)時適用。
注意:僅適用於透明物體的排序。這不會影響透明物體相對於不透明物體的排序方式。這是因為不透明物件不被排序,而透明物件則從後往前排序(取決於優先順序)。
如果為 true,則 Environment 中的 Light3D 會影響該標籤。
StructuredTextParser structured_text_bidi_override = 0 🔗
void set_structured_text_bidi_override(value: StructuredTextParser)
StructuredTextParser get_structured_text_bidi_override()
為結構化文字設定 BiDi 演算法覆蓋。
Array structured_text_bidi_override_options = [] 🔗
void set_structured_text_bidi_override_options(value: Array)
Array get_structured_text_bidi_override_options()
設定 BiDi 覆蓋的附加選項。
要在螢幕上顯示的文字。
Direction text_direction = 0 🔗
基礎文字書寫方向。
TextureFilter texture_filter = 3 🔗
void set_texture_filter(value: TextureFilter)
TextureFilter get_texture_filter()
Filter flags for the texture.
如果為 true,所有文字都將顯示為大寫。
VerticalAlignment vertical_alignment = 1 🔗
void set_vertical_alignment(value: VerticalAlignment)
VerticalAlignment get_vertical_alignment()
Controls the text's vertical alignment. Supports top, center, and bottom.
文字寬度(單位為圖元),用於自動換行和填充對齊。
方法說明
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.