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...
Upgrading from Godot 4.6 to Godot 4.7
For most games and apps made with 4.6 it should be relatively safe to migrate to 4.7. This page intends to cover everything you need to pay attention to when migrating your project.
做出更改
If you are migrating from 4.6 to 4.7, the breaking changes listed here might affect you. Changes are grouped by areas/systems.
這篇文章指出了每項破壞性改動是否會影響 GDScript,以及 C# 的破壞性改動是 二進位相容 還是 原始程式碼相容:
二進制相容 - 現有的二進制檔案無需重新編譯即可成功載入和執行,且運行時的行為不會改變。
** 原始程式碼相容** —— 在升級 Godot 時,原始程式碼可成功編譯,無需更改。
核心
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
Object |
||||
Method |
✔️ |
✔️ |
✔️ |
|
ZIPPacker |
||||
Method |
✔️ |
✔️ |
✔️ |
|
OptimizedTranslation |
||||
Method |
✔️ |
❌ |
✔️ |
2D
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
CPUParticles2D |
||||
Method |
✔️ |
✔️ |
✔️ |
|
GPUParticles2D |
||||
Method |
✔️ |
✔️ |
✔️ |
3D
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
CPUParticles3D |
||||
Method |
✔️ |
✔️ |
✔️ |
|
GPUParticles3D |
||||
Method |
✔️ |
✔️ |
✔️ |
建立節點
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
Control |
||||
Property |
✔️ |
❌ |
❌ |
|
RichTextLabel |
||||
Enum field |
❌ |
✔️ |
❌ |
|
Method |
✔️ |
✔️ |
✔️ |
|
Method |
✔️ |
✔️ |
✔️ |
|
Method |
✔️ |
✔️ |
❌ |
|
Method |
✔️ |
✔️ |
❌ |
|
Method |
✔️ |
✔️ |
✔️ |
|
Method |
✔️ |
✔️ |
✔️ |
|
Method |
✔️ |
✔️ |
❌ |
|
Method |
✔️ |
✔️ |
❌ |
文字
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
字型 |
||||
Method |
✔️ |
✔️ |
✔️ |
|
TreeItem |
||||
Method |
✔️ |
✔️ |
✔️ |
算繪
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
Image |
||||
Method |
✔️ |
✔️ |
✔️ |
|
Method |
✔️ |
✔️ |
✔️ |
|
ImageTexture |
||||
Method |
✔️ |
✔️ |
✔️ |
|
PortableCompressedTexture2D |
||||
Method |
✔️ |
✔️ |
✔️ |
|
RenderingServer |
||||
Method |
✔️ |
✔️ |
❌ |
|
Method |
✔️ |
✔️ |
✔️ |
動畫
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
動畫 |
||||
Property |
✔️ |
❌ |
❌ |
|
AnimationNodeBlendSpace1D |
||||
Method |
✔️ |
✔️ |
✔️ |
|
AnimationNodeBlendSpace2D |
||||
Method |
✔️ |
✔️ |
✔️ |
物理
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
PhysicsServer2D |
||||
Method |
✔️ |
✔️ |
✔️ |
|
PhysicsServer2DExtension |
||||
Method |
❌ |
❌ |
❌ |
音訊
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
AudioEffectSpectrumAnalyzer |
||||
Property |
❌ |
❌ |
❌ |
XR
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
OpenXRExtensionWrapper |
||||
Method |
❌ |
❌ |
❌ |
|
OpenXRSpatialAnchorCapability |
||||
Method |
✔️ |
✔️ |
✔️ |
編輯器
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
|---|---|---|---|---|
EditorSceneFormatImporter |
||||
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
Constant |
✔️ |
✔️ |
❌ |
|
EditorVCSInterface |
||||
Method |
❌ |
❌ |
❌ |
做出更改
動畫
備註
AnimationNodeBlendSpace1D and AnimationNodeBlendSpace2D have a new SyncMode
enum that replaces the previous boolean sync property. If you are using
an AnimationTree and your animations aren't transitioning correctly after
upgrading, you may need to set that value in each of your blend spaces to
get the desired behavior back.
The new sync modes are documented in AnimationNodeBlendSpace1D.sync_mode and AnimationNodeBlendSpace2D.sync_mode.
算繪
備註
The LinearToSRGB visual shader no longer clamps to the range [0.0, 1.0]
when using the Mobile or Forward+ renderer (GH-113956).
備註
CanvasItem now avoids adding the antialiasing feather when drawing lines (GH-105122).
The feather made lines appear thicker than intended, projects that relied on this behavior
will have to be updated to draw a thicker line width.
物理
備註
The default area_mask for AudioStreamPlayer was changed from 1 to 0 (disabled) (GH-107679).
If you use the audio_bus_override feature on Area2D or Area3D, and you
use the AudioStreamPlayer default area_mask (just layer 1 ticked), you will need
to reset the mask to layer 1 — otherwise, the bus overrides will stop working.
If the mask was set to anything except layer 1, it will continue to work as expected.
備註
When using Jolt Physics as the 3D physics engine, WorldBoundaryShape3D will now use the same
convention as Godot when applying WorldBoundaryShape3D.plane.d, resulting in the sign of the plane
distance being interpreted in the opposite way compared to Godot 4.6 (GH-118948). You will need to flip
the sign yourself to get the same behavior as in Godot 4.6.
備註
When using Jolt Physics as the 3D physics engine, SoftBody3D will no longer default its mass to 0,
which resulted in an automatically calculated weight of 1 kg per point, resulting in a very high total
mass for the body. Now instead it will default to 1 kg for the entire SoftBody3D, same as Godot
Physics (GH-116041).
備註
When using Jolt Physics as the 3D physics engine, SoftBody3D will now apply
SoftBody3D.linear_stiffness in a way that better matches Godot Physics, and in a way that's more
appropriate in general (GH-116041). This will affect every SoftBody3D instance in one way or
another, meaning you will need to re-tweak properties like SoftBody3D.linear_stiffness and
SoftBody3D.damping_coefficient to achieve your desired behavior.
備註
When using Jolt Physics as the 3D physics engine, Area3D will now report overlaps with SoftBody3D
from its various signals and methods (GH-114198). To work around this breaking change, configure your
collision layers/masks such that any undesirable interactions between Area3D and SoftBody3D are
ignored.
輸入
備註
The device IDs for mouse and keyboard were changed from 0 to InputEvent.DEVICE_ID_MOUSE and
InputEvent.DEVICE_ID_KEYBOARD because some joypads may use 0 as their ID (GH-116274).
Check the input event by type or compare the device ID InputEvent.device to the constants
InputEvent.DEVICE_ID_MOUSE and InputEvent.DEVICE_ID_KEYBOARD instead.
GDScript
備註
Setting the element of packed arrays no longer calls the setter for the entire packed array property (GH-113228).
備註
Methods that inherit from a method with a typed return now inherit the return type as well,
requiring an explicit return statement in the override (GH-115763).
Add return null to the end of the method to fix the error.
支援平台
備註
The minimum macOS version required to run Godot was increased from macOS 10.13 (High Sierra) to macOS 11 (Big Sur).
Changed defaults
The following default values have been changed. If your project uses any of these properties with their default value, you can achieve a similar behavior to the previous version by manually setting the values to match the old defaults.
備註
The default stretch mode and stretch aspect for newly created projects
is now canvas_items and expand respectively (previously disabled
and keep). This can be changed in the Project Settings under
display/window/stretch/mode and display/window/stretch/aspect.
動畫
Property/Parameter |
Old Default |
New Default |
|---|---|---|
LookAtModifier3D |
||
Property |
true |
false |
核心
Property/Parameter |
Old Default |
New Default |
|---|---|---|
ProjectSettings |
||
Property |
7 |
8 |
建立節點
Property/Parameter |
Old Default |
New Default |
|---|---|---|
RichTextLabel |
||
Method |
false |
0 |
Method |
false |
0 |
Method |
false |
0 |
Method |
false |
0 |
匯入
Property/Parameter |
Old Default |
New Default |
|---|---|---|
ResourceImporterDynamicFont |
||
Property |
1 |
3 |