introduction_to_editor_development.rst 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. .. _doc_introduction_to_editor_development:
  2. Introduction to editor development
  3. ==================================
  4. On this page, you will learn:
  5. - The **design decisions** behind the Godot editor.
  6. - How to work efficiently on the Godot editor's C++ code.
  7. This guide is aimed at current or future engine contributors.
  8. To create editor plugins in GDScript, see :ref:`doc_making_plugins` instead.
  9. .. seealso::
  10. If you are new to Godot, we recommended you to read
  11. :ref:`doc_godot_design_philosophy` before continuing. Since the Godot editor
  12. is a Godot project written in C++, much of the engine's philosophy applies
  13. to the editor.
  14. Technical choices
  15. -----------------
  16. The Godot editor is drawn using Godot's renderer and
  17. :ref:`UI system <toc-learn-features-gui>`. It does *not* rely on a toolkit
  18. such as GTK or Qt. This is similar in spirit to software like Blender.
  19. While using toolkits makes it easier to achieve a "native" appearance, they are
  20. also quite heavy and their licensing is not compatible with Godot's.
  21. The editor is fully written in C++. It can't contain any GDScript or C# code.
  22. Directory structure
  23. -------------------
  24. The editor's code is fully self-contained in the
  25. `editor/ <https://github.com/godotengine/godot/tree/master/editor>`__ folder
  26. of the Godot source repository.
  27. Some editor functionality is also implemented via
  28. :ref:`modules <doc_custom_modules_in_c++>`. Some of these are only enabled in
  29. editor builds to decrease the binary size of export templates. See the
  30. `modules/ <https://github.com/godotengine/godot/tree/master/modules>`__ folder
  31. in the Godot source repository.
  32. Some important files in the editor are:
  33. - `editor/editor_node.cpp <https://github.com/godotengine/godot/blob/3.x/editor/editor_node.cpp>`__: Main editor initialization file.
  34. - `editor/plugins/canvas_item_editor_plugin.cpp <https://github.com/godotengine/godot/blob/3.x/editor/plugins/canvas_item_editor_plugin.cpp>`__:
  35. The 2D editor viewport and related functionality (toolbar at the top, editing modes, overlaid helpers/panels, …).
  36. - `editor/plugins/spatial_editor_plugin.cpp <https://github.com/godotengine/godot/blob/3.x/editor/plugins/spatial_editor_plugin.cpp>`__:
  37. The 3D editor viewport and related functionality (toolbar at the top, editing modes, overlaid panels, …).
  38. - `editor/spatial_editor_gizmos.cpp <https://github.com/godotengine/godot/blob/3.x/editor/spatial_editor_gizmos.cpp>`__:
  39. Where the 3D editor gizmos are defined and drawn.
  40. This file doesn't have a 2D counterpart as 2D gizmos are drawn by the nodes themselves.
  41. Editor dependencies in ``scene/`` files
  42. ---------------------------------------
  43. When working on an editor feature, you may have to modify files in
  44. Godot's GUI nodes, which you can find in the ``scene/`` folder.
  45. One rule to keep in mind is that you must **not** introduce new dependencies to
  46. ``editor/`` includes in other folders such as ``scene/``. This applies even if
  47. you use ``#ifdef TOOLS_ENABLED``.
  48. To make the codebase easier to follow and more self-contained, the allowed
  49. dependency order is:
  50. - ``editor/`` -> ``scene/`` -> ``servers/`` -> ``core/``
  51. This means that files in ``editor/`` can depend on includes from ``scene/``,
  52. ``servers/``, and ``core/``. But, for example, while ``scene/`` can depend on includes
  53. from ``servers/`` and ``core/``, it cannot depend on includes from ``editor/``.
  54. Currently, there are some dependencies to ``editor/`` includes in ``scene/``
  55. files, but
  56. `they are in the process of being removed <https://github.com/godotengine/godot/issues/29730>`__.
  57. Development tips
  58. ----------------
  59. To iterate quickly on the editor, we recommend to set up a test project and
  60. :ref:`open it from the command line <doc_command_line_tutorial>` after compiling
  61. the editor. This way, you don't have to go through the project manager every
  62. time you start Godot.