introduction_to_editor_development.rst 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 <doc_user_interface>`. 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_cpp>`. 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/master/editor/editor_node.cpp>`__:
  34. Main editor initialization file. Effectively the "main scene" of the editor.
  35. - `editor/project_manager.cpp <https://github.com/godotengine/godot/blob/master/editor/project_manager.cpp>`__:
  36. Main Project Manager initialization file. Effectively the "main scene" of the Project Manager.
  37. - `editor/plugins/canvas_item_editor_plugin.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/canvas_item_editor_plugin.cpp>`__:
  38. The 2D editor viewport and related functionality (toolbar at the top, editing modes, overlaid helpers/panels, …).
  39. - `editor/plugins/node_3d_editor_plugin.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/node_3d_editor_plugin.cpp>`__:
  40. The 3D editor viewport and related functionality (toolbar at the top, editing modes, overlaid panels, …).
  41. - `editor/plugins/node_3d_editor_gizmos.cpp <https://github.com/godotengine/godot/blob/master/editor/plugins/node_3d_editor_gizmos.cpp>`__:
  42. Where the 3D editor gizmos are defined and drawn.
  43. This file doesn't have a 2D counterpart as 2D gizmos are drawn by the nodes themselves.
  44. Editor dependencies in ``scene/`` files
  45. ---------------------------------------
  46. When working on an editor feature, you may have to modify files in
  47. Godot's GUI nodes, which you can find in the ``scene/`` folder.
  48. One rule to keep in mind is that you must **not** introduce new dependencies to
  49. ``editor/`` includes in other folders such as ``scene/``. This applies even if
  50. you use ``#ifdef TOOLS_ENABLED``.
  51. To make the codebase easier to follow and more self-contained, the allowed
  52. dependency order is:
  53. - ``editor/`` -> ``scene/`` -> ``servers/`` -> ``core/``
  54. This means that files in ``editor/`` can depend on includes from ``scene/``,
  55. ``servers/``, and ``core/``. But, for example, while ``scene/`` can depend on includes
  56. from ``servers/`` and ``core/``, it cannot depend on includes from ``editor/``.
  57. Currently, there are some dependencies to ``editor/`` includes in ``scene/``
  58. files, but
  59. `they are in the process of being removed <https://github.com/godotengine/godot/issues/53295>`__.
  60. Development tips
  61. ----------------
  62. To iterate quickly on the editor, we recommend to set up a test project and
  63. :ref:`open it from the command line <doc_command_line_tutorial>` after compiling
  64. the editor. This way, you don't have to go through the Project Manager every
  65. time you start Godot.