编辑器开发简介

在这一页,你将了解到:

  • 设计决策
  • 如何高效地处理Godot编辑器的C++代码。 制作插件 。 参见 Godot 的设计理念 。由于 Godot 编辑器是用 C++ 编写的 Godot 项目,引擎的许多理念同样适用于编辑器。

    技术选择

    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#代码。

    目录结构

    editor/ 文件夹中。 modules 实现的。其中一些只在编辑器构建中启用,以减少导出模板的二进制文件大小。参见Godot源码库中的 modules/ 文件夹。 编辑器中的一些重要文件包括:
  • editor/editor_node.cpp :主编辑器初始化文件。相当于编辑器的“主场景”。
  • editor/editor_node.cpp :主编辑器初始化文件。相当于编辑器的“主场景”。
  • editor/plugins/canvas_item_editor_plugin.cpp: 2D编辑器的视窗和相关功能,顶部的工具栏、编辑模式、重叠的助手/面板等…。
  • editor/plugins/spatial_editor_plugin.cpp: 三维编辑器视窗及相关功能,顶部的工具栏、编辑模式、叠加面板等…。
  • editor/spatial_editor_gizmos.cpp: 定义和绘制3D编辑器小工具的地方. 这个文件没有2D的对应文件,因为2D的小工具是由节点自己绘制的。

    scene/ 中文件对编辑器的依赖性

    scene/ 文件夹中找到。 不能editor/ 在其他文件夹中引入新的依赖关系,如 scene/。即使你使用 #ifdef TOOLS_ENABLED 也是如此。 为了使代码库更容易操作,更自成一体,允许的依赖性顺序是:
  • editor/ -> scene/ -> servers/ -> core/ editor/ 中的文件可以依赖 scene/, servers/, 和 core/ 中的包含。但是,虽然 scene/ 可以依赖 servers/core/ 的内容,但它不能依赖 editor/ 的内容。 scene/ 文件中存在一些对 editor/ 的依赖,但 它们正在被删除 。

    开发技巧

    从命令行打开。这样,你就不必在每次启动 Godot 时都要经过项目管理器了。