Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
编辑器开发简介¶
在这一页,你将了解到:
Godot 编辑器背后的设计决策。
如何高效地处理Godot编辑器的C++代码。
本指南针对的是目前或未来的引擎贡献者。要在GDScript中创建编辑器插件,请参见 制作插件 。
参见
如果你是 Godot 的新手,建议你在继续之前先阅读 Godot 的设计理念 。由于 Godot 编辑器是用 C++ 编写的 Godot 项目,引擎的许多理念同样适用于编辑器。
技术选择¶
The Godot editor is drawn using Godot's renderer and UI system. It does not rely on a toolkit such as GTK or Qt. This is similar in spirit to software like Blender. While using toolkits makes it easier to achieve a "native" appearance, they are also quite heavy and their licensing is not compatible with Godot's.
该编辑器完全是用C++编写的。它不能包含任何GDScript或C#代码。
目录结构¶
编辑器的代码完全独立于Godot源代码库的 editor/ 文件夹中。
Some editor functionality is also implemented via modules. Some of these are only enabled in editor builds to decrease the binary size of export templates. See the modules/ folder in the Godot source repository.
编辑器中的一些重要文件包括:
editor/editor_node.cpp:主编辑器初始化文件。相当于编辑器的“主场景”。
editor/project_manager.cpp:主项目管理器初始化文件。相当于项目管理器的“主场景”。
editor/plugins/canvas_item_editor_plugin.cpp: The 2D editor viewport and related functionality (toolbar at the top, editing modes, overlaid helpers/panels, …).
editor/plugins/node_3d_editor_plugin.cpp: The 3D editor viewport and related functionality (toolbar at the top, editing modes, overlaid panels, …).
editor/plugins/node_3d_editor_gizmos.cpp: Where the 3D editor gizmos are defined and drawn. This file doesn't have a 2D counterpart as 2D gizmos are drawn by the nodes themselves.
scene/
中文件对编辑器的依赖性¶
在处理编辑器功能时,你可能需要修改Godot的GUI节点中的文件,你可以在 scene/
文件夹中找到。
需要记住的一条规则是,你不能给 editor/
在其他文件夹中引入新的依赖关系,如