Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ProgressBar

继承: Range < Control < CanvasItem < Node < Object

将百分比可视化表示的控件。

描述

将百分比可视化表示的控件。显示从右到左的填充百分比。

属性

int

fill_mode

0

bool

show_percentage

true

主题属性

Color

font_color

Color(0.95, 0.95, 0.95, 1)

Color

font_outline_color

Color(1, 1, 1, 1)

int

outline_size

0

Font

font

int

font_size

StyleBox

background

StyleBox

fill


枚举

enum FillMode:

FillMode FILL_BEGIN_TO_END = 0

进度条从开头到结尾水平填充,开头和结尾的位置取决于语言的方向。如果 Control.is_layout_rtl 返回 false 则为从左至右填充,如果返回 true 则为从右至左填充。

FillMode FILL_END_TO_BEGIN = 1

进度条从结尾到开头水平填充,开头和结尾的位置取决于语言的方向。如果 Control.is_layout_rtl 返回 false 则为从左至右填充,如果返回 true 则为从右至左填充。

FillMode FILL_TOP_TO_BOTTOM = 2

进度从上到下填充。

FillMode FILL_BOTTOM_TO_TOP = 3

进度从下到上填充。


属性说明

int fill_mode = 0

  • void set_fill_mode ( int value )

  • int get_fill_mode ( )

填充方向。可能的取值见 FillMode


bool show_percentage = true

  • void set_show_percentage ( bool value )

  • bool is_percentage_shown ( )

true 时,将在进度条上显示百分比。


主题属性说明

Color font_color = Color(0.95, 0.95, 0.95, 1)

文本的颜色。


Color font_outline_color = Color(1, 1, 1, 1)

ProgressBar 的文本轮廓的色调。


int outline_size = 0

文字轮廓的大小。

注意:如果使用启用了 FontFile.multichannel_signed_distance_field 的字体,其 FontFile.msdf_pixel_range 必须至少设置为 outline_size两倍,轮廓渲染才能看起来正确。否则,轮廓可能会比预期的更早被切断。


Font font

show_percentagetrue 时,用于绘制填充百分比的字体。


int font_size

show_percentagetrue 时,用于绘制填充百分比的字体。


StyleBox background

背景的样式。


StyleBox fill

进度的样式(即填充进度条的部分)。