Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
從 Godot 4.0 升級到 Godot 4.1¶
對於大多數使用 4.0 製作的遊戲和應用程式來說,遷移到 4.1 應該相對安全。本頁旨在介紹遷移專案時需要注意的所有事項。
做出更改¶
如果你要從 4.0 遷移到 4.1,這裡列出的破壞性更改可能會影響到你。更改按照領域/系統群組。
警告
GDExtension API 在 4.1 中完全不相容,因此未列入下表。更多資訊請參見 將 GDExtension 更新到 4.1 部分。
這篇文章指出了每項破壞性改動是否會影響 GDScript,以及 C# 的破壞性改動是 二進位相容 還是 原始程式碼相容:
二進位相容 —— 現有二進位檔案無需重新編譯即可載入並成功執行,運作時的行為不會改變。
** 原始程式碼相容** —— 在升級 Godot 時,原始程式碼可成功編譯,無需更改。
核心¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
Basis |
||||
|
✔️ |
✔️ |
✔️ |
|
Object |
||||
|
✔️ |
❌ |
❌ |
|
Transform3D |
||||
|
✔️ |
✔️ |
✔️ |
|
UndoRedo |
||||
|
✔️ |
✔️ |
✔️ |
|
WorkerThreadPool |
||||
|
✔️ |
❌ |
✔️ |
動畫¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
動畫模式 |
||||
|
❌ |
❌ |
❌ |
|
|
✔️ |
✔️ |
✔️ |
|
|
✔️ |
✔️ |
✔️ |
|
AnimationNodeStateMachinePlayback |
||||
|
✔️ |
❌ |
❌ |
節點¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
PathFollow2D |
||||
移除了 |
❌ |
❌ |
❌ |
節點¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
一般: |
||||
方法 |
✔️ |
✔️ |
❌ |
|
使用泛型方法 |
||||
方法 |
✔️ |
✔️ |
✔️ |
|
節點: |
||||
方法 |
✔️ |
✔️ |
✔️ |
|
方法 |
✔️ |
✔️ |
✔️ |
建立節點¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
CodeEdit |
||||
方法 |
✔️ |
✔️ |
✔️ |
|
RichTextLabel |
||||
方法 |
✔️ |
✔️ |
✔️ |
|
方法 |
✔️ |
✔️ |
✔️ |
|
方法 |
✔️ |
✔️ |
✔️ |
|
是 |
||||
方法 |
✔️ |
✔️ |
✔️ |
物理¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
Area2D |
||||
屬性 |
❌ |
❌ |
❌ |
|
Area3D |
||||
屬性 |
❌ |
❌ |
❌ |
|
PhysicsDirectSpaceState2D |
||||
方法 |
❌ |
❌ |
❌ |
|
PhysicsDirectSpaceState3D |
||||
方法 |
❌ |
❌ |
❌ |
渲染¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
RDShaderFile |
||||
方法 |
✔️ |
❌ |
❌ |
|
渲染 |
||||
方法 |
✔️ |
✔️ |
❌ |
|
RenderingServer |
||||
方法 |
✔️ |
❌ |
❌ |
|
建立內容 |
||||
方法 |
✔️ |
✔️ |
❌ |
網路¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
WebRTCPeerConnectionExtension |
||||
方法 |
✔️ |
❌ |
✔️ |
編輯器外掛程式¶
改動 |
GDScript 格式化字串 |
C# 二進位相容 |
C# 原始程式碼相容 |
簡介 |
---|---|---|---|---|
動畫軌編輯器 |
||||
動畫軌編輯器 |
❌ |
❌ |
❌ |
|
編輯器界面 (C++) |
||||
|
✔️ |
❌ |
❌ |
|
方法 |
✔️ |
❌ |
❌ |
|
方法 |
✔️ |
❌ |
❌ |
|
EditorResourcePreviewGenerator |
||||
|
❌ |
❌ |
❌ |
|
|
❌ |
❌ |
❌ |
|
EditorUndoRedoManager |
||||
|
✔️ |
✔️ |
✔️ |
做出更改¶
4.1 中引入了一些行為的更改,你可能需要調整專案。
改動 |
簡介 |
---|---|
建立內容 |
|
當輸入事件應傳播到 SubViewport 及其子節點時, |
|
如果多層 |
|
檢視區 |
|
啟用 Physics Picking 的 |
將 GDExtension 更新到 4.1¶
GDExtension 仍處於測試階段。在它被標記為穩定版之前,升級到新的 Godot 小版本時可能會出現相容性問題。
為了修復一個嚴重的錯誤,在 Godot 4.1 中,我們不得不在很大程度上打破二進位相容性,在很小程度上打破原始程式碼相容性。
這意味著為 Godot 4.0 製作的 GDExtensions 將需要為 Godot 4.1 重新編譯(使用 godot-cpp 的 4.1
分支),並對其原始程式碼稍作修改。
最後場景應該長這樣。
GDExtensionBool GDE_EXPORT example_library_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module);
init_obj.register_terminator(uninitialize_example_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
不過,對於 Godot 4.1 來說,它應該是這樣的:
GDExtensionBool GDE_EXPORT example_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
init_obj.register_initializer(initialize_example_module);
init_obj.register_terminator(uninitialize_example_module);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
return init_obj.init();
}
有下列事項需注意:
第一個參數從
const GDExtensionInterface *p_interface
改為GDExtensionInterfaceGetProcAddress p_get_proc_address
init_obj 變數的建構子現在會接收
p_get_proc_address
作為第一個參數
您還需要在 .gdextension
檔中新增額外的 compatibility_minimum
行,使其看起來類似於:
[configuration]
entry_symbol = "example_library_init"
compatibility_minimum = 4.1
這會讓 Godot 知道您的 GDExtension 已經更新,可以在 Godot 4.1 中安全載入。