编辑器开发简介
在这一页,你将了解到:
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/
在其他文件夹中引入新的依赖关系,如 scene/
。即使你使用 #ifdef TOOLS_ENABLED
也是如此。
为了使代码库更容易操作,更自成一体,允许的依赖性顺序是:
editor/
->scene/
->servers/
->core/
这意味着 editor/
中的文件可以依赖 scene/
, servers/
, 和 core/
中的包含。但是,虽然 scene/
可以依赖 servers/
和 core/
的内容,但它不能依赖 editor/
的内容。
Currently, there are some dependencies to editor/
includes in scene/
files, but they are in the process of being removed.
开发技巧
To iterate quickly on the editor, we recommend to set up a test project and open it from the command line after compiling the editor. This way, you don’t have to go through the Project Manager every time you start Godot.
© 版权所有 2014-present Juan Linietsky, Ariel Manzur and the Godot community (CC BY 3.0). Revision b1c660f7
.
Built with Sphinx using a theme provided by Read the Docs.