Up to date

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

@GlobalScope

全局范围的常量和函数。

描述

全局范围的枚举常量和内置函数的列表。这是所有驻留在全局的,关于错误代码、键码、属性提示等的常量。

单例也被记录在这里,因为它们可以从任何地方被访问。

对于可以在任何脚本中访问的与 GDScript 相关的条目,请参阅 @GDScript

备注

通过 C# 使用这个 API 时有显著的不同。详见 C# API 与 GDScript 的差异

教程

属性

AudioServer

AudioServer

CameraServer

CameraServer

ClassDB

ClassDB

DisplayServer

DisplayServer

EditorInterface

EditorInterface

Engine

Engine

EngineDebugger

EngineDebugger

GDExtensionManager

GDExtensionManager

Geometry2D

Geometry2D

Geometry3D

Geometry3D

GodotSharp

GodotSharp

IP

IP

Input

Input

InputMap

InputMap

JavaClassWrapper

JavaClassWrapper

JavaScriptBridge

JavaScriptBridge

Marshalls

Marshalls

NavigationMeshGenerator

NavigationMeshGenerator

NavigationServer2D

NavigationServer2D

NavigationServer3D

NavigationServer3D

OS

OS

Performance

Performance

PhysicsServer2D

PhysicsServer2D

PhysicsServer2DManager

PhysicsServer2DManager

PhysicsServer3D

PhysicsServer3D

PhysicsServer3DManager

PhysicsServer3DManager

ProjectSettings

ProjectSettings

RenderingServer

RenderingServer

ResourceLoader

ResourceLoader

ResourceSaver

ResourceSaver

ResourceUID

ResourceUID

TextServerManager

TextServerManager

ThemeDB

ThemeDB

Time

Time

TranslationServer

TranslationServer

WorkerThreadPool

WorkerThreadPool

XRServer

XRServer

方法

Variant

abs ( Variant x )

float

absf ( float x )

int

absi ( int x )

float

acos ( float x )

float

acosh ( float x )

float

angle_difference ( float from, float to )

float

asin ( float x )

float

asinh ( float x )

float

atan ( float x )

float

atan2 ( float y, float x )

float

atanh ( float x )

float

bezier_derivative ( float start, float control_1, float control_2, float end, float t )

float

bezier_interpolate ( float start, float control_1, float control_2, float end, float t )

Variant

bytes_to_var ( PackedByteArray bytes )

Variant

bytes_to_var_with_objects ( PackedByteArray bytes )

Variant

ceil ( Variant x )

float

ceilf ( float x )

int

ceili ( float x )

Variant

clamp ( Variant value, Variant min, Variant max )

float

clampf ( float value, float min, float max )

int

clampi ( int value, int min, int max )

float

cos ( float angle_rad )

float

cosh ( float x )

float

cubic_interpolate ( float from, float to, float pre, float post, float weight )

float

cubic_interpolate_angle ( float from, float to, float pre, float post, float weight )

float

cubic_interpolate_angle_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

float

cubic_interpolate_in_time ( float from, float to, float pre, float post, float weight, float to_t, float pre_t, float post_t )

float

db_to_linear ( float db )

float

deg_to_rad ( float deg )

float

ease ( float x, float curve )

String

error_string ( int error )

float

exp ( float x )

Variant

floor ( Variant x )

float

floorf ( float x )

int

floori ( float x )

float

fmod ( float x, float y )

float

fposmod ( float x, float y )

int

hash ( Variant variable )

Object

instance_from_id ( int instance_id )

float

inverse_lerp ( float from, float to, float weight )

bool

is_equal_approx ( float a, float b )

bool

is_finite ( float x )

bool

is_inf ( float x )

bool

is_instance_id_valid ( int id )

bool

is_instance_valid ( Variant instance )

bool

is_nan ( float x )

bool

is_same ( Variant a, Variant b )

bool

is_zero_approx ( float x )

Variant

lerp ( Variant from, Variant to, Variant weight )

float

lerp_angle ( float from, float to, float weight )

float

lerpf ( float from, float to, float weight )

float

linear_to_db ( float lin )

float

log ( float x )

Variant

max ( ... ) vararg

float

maxf ( float a, float b )

int

maxi ( int a, int b )

Variant

min ( ... ) vararg

float

minf ( float a, float b )

int

mini ( int a, int b )

float

move_toward ( float from, float to, float delta )

int

nearest_po2 ( int value )

float

pingpong ( float value, float length )

int

posmod ( int x, int y )

float

pow ( float base, float exp )

void

print ( ... ) vararg

void

print_rich ( ... ) vararg

void

print_verbose ( ... ) vararg

void

printerr ( ... ) vararg

void

printraw ( ... ) vararg

void

prints ( ... ) vararg

void

printt ( ... ) vararg

void

push_error ( ... ) vararg

void

push_warning ( ... ) vararg

float

rad_to_deg ( float rad )

PackedInt64Array

rand_from_seed ( int seed )

float

randf ( )

float

randf_range ( float from, float to )

float

randfn ( float mean, float deviation )

int

randi ( )

int

randi_range ( int from, int to )

void

randomize ( )

float

remap ( float value, float istart, float istop, float ostart, float ostop )

int

rid_allocate_id ( )

RID

rid_from_int64 ( int base )

float

rotate_toward ( float from, float to, float delta )

Variant

round ( Variant x )

float

roundf ( float x )

int

roundi ( float x )

void

seed ( int base )

Variant

sign ( Variant x )

float

signf ( float x )

int

signi ( int x )

float

sin ( float angle_rad )

float

sinh ( float x )

float

smoothstep ( float from, float to, float x )

Variant

snapped ( Variant x, Variant step )

float

snappedf ( float x, float step )

int

snappedi ( float x, int step )

float

sqrt ( float x )

int

step_decimals ( float x )

String

str ( ... ) vararg

Variant

str_to_var ( String string )

float

tan ( float angle_rad )

float

tanh ( float x )

Variant

type_convert ( Variant variant, int type )

String

type_string ( int type )

int

typeof ( Variant variable )

PackedByteArray

var_to_bytes ( Variant variable )

PackedByteArray

var_to_bytes_with_objects ( Variant variable )

String

var_to_str ( Variant variable )

Variant

weakref ( Variant obj )

Variant

wrap ( Variant value, Variant min, Variant max )

float

wrapf ( float value, float min, float max )

int

wrapi ( int value, int min, int max )


枚举

enum Side:

Side SIDE_LEFT = 0

左边,常用于 ControlStyleBox 的派生类。

Side SIDE_TOP = 1

顶边,常用于 ControlStyleBox 的派生类。

Side SIDE_RIGHT = 2

右边,常用于 ControlStyleBox 的派生类。

Side SIDE_BOTTOM = 3

底边,常用于 ControlStyleBox 的派生类。


enum Corner:

Corner CORNER_TOP_LEFT = 0

左上角。

Corner CORNER_TOP_RIGHT = 1

右上角。

Corner CORNER_BOTTOM_RIGHT = 2

右下角。

Corner CORNER_BOTTOM_LEFT = 3

左下角。


enum Orientation:

Orientation VERTICAL = 1

通用垂直对齐,常用于 SeparatorScrollBarSlider 等。

Orientation HORIZONTAL = 0

通用水平对齐,常用于 SeparatorScrollBarSlider 等。


enum ClockDirection:

ClockDirection CLOCKWISE = 0

顺时针旋转。被一些方法使用(例如 Image.rotate_90)。

ClockDirection COUNTERCLOCKWISE = 1

逆时针旋转。被一些方法使用(例如 Image.rotate_90)。


enum HorizontalAlignment:

HorizontalAlignment HORIZONTAL_ALIGNMENT_LEFT = 0

水平左对齐,常用于文本派生类。

HorizontalAlignment HORIZONTAL_ALIGNMENT_CENTER = 1

水平居中对齐,常用于文本派生类。

HorizontalAlignment HORIZONTAL_ALIGNMENT_RIGHT = 2

水平右对齐,常用于文本派生类。

HorizontalAlignment HORIZONTAL_ALIGNMENT_FILL = 3

扩展行以适应宽度,常用于文本派生类。


enum VerticalAlignment:

VerticalAlignment VERTICAL_ALIGNMENT_TOP = 0

垂直上对齐,常用于文本派生类。

VerticalAlignment VERTICAL_ALIGNMENT_CENTER = 1

垂直居中对齐,常用于文本派生类。

VerticalAlignment VERTICAL_ALIGNMENT_BOTTOM = 2

垂直下对齐,常用于文本派生类。

VerticalAlignment VERTICAL_ALIGNMENT_FILL = 3

扩展行以适应高度,通常用于文本派生类。


enum InlineAlignment:

InlineAlignment INLINE_ALIGNMENT_TOP_TO = 0

将内联对象(例如图像、表格)的顶部与 INLINE_ALIGNMENT_TO_* 常量指定的文本位置对齐。

InlineAlignment INLINE_ALIGNMENT_CENTER_TO = 1

将内联对象(例如图像、表格)的中心与 INLINE_ALIGNMENT_TO_* 常量指定的文本位置对齐。

InlineAlignment INLINE_ALIGNMENT_BASELINE_TO = 3

将内联对象(如图像、表格)的基线(用户定义)与INLINE_ALIGNMENT_TO_* 常数指定的文本位置对齐。

InlineAlignment INLINE_ALIGNMENT_BOTTOM_TO = 2

将内联对象(例如图像、表格)的底部与 INLINE_ALIGNMENT_TO_* 常量指定的文本位置对齐。

InlineAlignment INLINE_ALIGNMENT_TO_TOP = 0

将由 INLINE_ALIGNMENT_*_TO 常量指定的内联对象(例如图像、表格)的位置与文本顶部对齐。

InlineAlignment INLINE_ALIGNMENT_TO_CENTER = 4

将由 INLINE_ALIGNMENT_*_TO 常量指定的内联对象(例如图像、表格)的位置与文本中心对齐。

InlineAlignment INLINE_ALIGNMENT_TO_BASELINE = 8

将由 INLINE_ALIGNMENT_*_TO 常量指定的内联对象(例如图像、表格)的位置与文本基线对齐。

InlineAlignment INLINE_ALIGNMENT_TO_BOTTOM = 12

将内联对象(例如图像、表格)与文本底部对齐。

InlineAlignment INLINE_ALIGNMENT_TOP = 0

将内联对象(例如图像、表格)的顶部与文本的顶部对齐。等效于 INLINE_ALIGNMENT_TOP_TO | INLINE_ALIGNMENT_TO_TOP

InlineAlignment INLINE_ALIGNMENT_CENTER = 5

将内联对象(例如图像、表格)的中心与文本的中心对齐。相当于 INLINE_ALIGNMENT_CENTER_TO | INLINE_ALIGNMENT_TO_CENTER

InlineAlignment INLINE_ALIGNMENT_BOTTOM = 14

将内联对象(例如图像、表格)的底部与文本底部对齐。等效于 INLINE_ALIGNMENT_BOTTOM_TO | INLINE_ALIGNMENT_TO_BOTTOM

InlineAlignment INLINE_ALIGNMENT_IMAGE_MASK = 3

用于 INLINE_ALIGNMENT_*_TO 对齐常量的位掩码。

InlineAlignment INLINE_ALIGNMENT_TEXT_MASK = 12

用于 INLINE_ALIGNMENT_TO_* 对齐常量的位掩码。


enum EulerOrder:

EulerOrder EULER_ORDER_XYZ = 0

指定欧拉角应按 XYZ 顺序排列。组合时,顺序为 X、Y、Z。分解时,顺序相反,先 Z,再 Y,最后 X。

EulerOrder EULER_ORDER_XZY = 1

指定欧拉角应按 XZY 顺序排列。组合时,顺序为 X、Z、Y。分解时,顺序相反,先 Y,再 Z,最后 X。

EulerOrder EULER_ORDER_YXZ = 2

指定欧拉角应按 YXZ 顺序排列。组合时,顺序为 Y、X、Z。分解时,顺序相反,先 Z,再 X,最后 Y。

EulerOrder EULER_ORDER_YZX = 3

指定欧拉角应按 YZX 顺序排列。组合时,顺序为 Y、Z、X。分解时,顺序相反,先 X,再 Z,最后 Y。

EulerOrder EULER_ORDER_ZXY = 4

指定欧拉角应按 ZXY 顺序排列。组合时,顺序为 Z、X、Y。分解时,顺序相反,先 Y,再 X,最后 Z。

EulerOrder EULER_ORDER_ZYX = 5

指定欧拉角应按 ZYX 顺序排列。组合时,顺序为 Z、Y、X。分解时,顺序相反,先 X,再 Y,最后 Z。


enum Key:

Key KEY_NONE = 0

与任何键都不对应的枚举值。这用于初始化具有通用状态的 Key 属性。

Key KEY_SPECIAL = 4194304

应用此位的键码不可打印。

Key KEY_ESCAPE = 4194305

ESC 键。

Key KEY_TAB = 4194306

Tab 键。

Key KEY_BACKTAB = 4194307

Shift + Tab 键。

Key KEY_BACKSPACE = 4194308

退格键。

Key KEY_ENTER = 4194309

回车键(位于主键盘)。

Key KEY_KP_ENTER = 4194310

小键盘区的回车键。

Key KEY_INSERT = 4194311

Insert 键。

Key KEY_DELETE = 4194312

Delete 键。

Key KEY_PAUSE = 4194313

Pause 键。

Key KEY_PRINT = 4194314

Print Screen 键。

Key KEY_SYSREQ = 4194315

System Request 键。

Key KEY_CLEAR = 4194316

Clear 键。

Key KEY_HOME = 4194317

Home 键。

Key KEY_END = 4194318

End 键。

Key KEY_LEFT = 4194319

左方向键。

Key KEY_UP = 4194320

上方向键。

Key KEY_RIGHT = 4194321

右方向键。

Key KEY_DOWN = 4194322

下方向键。

Key KEY_PAGEUP = 4194323

Page Up 键。

Key KEY_PAGEDOWN = 4194324

Page Down 键。

Key KEY_SHIFT = 4194325

Shift 键。

Key KEY_CTRL = 4194326

Control 键。

Key KEY_META = 4194327

Meta 键。

Key KEY_ALT = 4194328

Alt 键。

Key KEY_CAPSLOCK = 4194329

Caps Lock 键。

Key KEY_NUMLOCK = 4194330

Num Lock 键。

Key KEY_SCROLLLOCK = 4194331

Scroll Lock 键。

Key KEY_F1 = 4194332

F1 键。

Key KEY_F2 = 4194333

F2 键。

Key KEY_F3 = 4194334

F3 键。

Key KEY_F4 = 4194335

F4 键。

Key KEY_F5 = 4194336

F5 键。

Key KEY_F6 = 4194337

F6 键。

Key KEY_F7 = 4194338

F7 键。

Key KEY_F8 = 4194339

F8 键。

Key KEY_F9 = 4194340

F9 键。

Key KEY_F10 = 4194341

F10 键。

Key KEY_F11 = 4194342

F11 键。