creating_icons.rst 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. .. _doc_editor_icons:
  2. Editor icons
  3. ============
  4. When a new class is created and exposed to scripting, the editor's interface
  5. will display it with a default icon representing the base class it inherits
  6. from. Yet in most cases it is recommended to create icons for new classes
  7. to improve the user experience.
  8. Creating icons
  9. ~~~~~~~~~~~~~~
  10. To create new icons, you first need a vector graphics editor installed.
  11. For instance, you can use the open source `Inkscape <https://inkscape.org/>`_ editor.
  12. Clone the ``godot`` repository containing all the editor icons:
  13. .. code-block:: bash
  14. git clone https://github.com/godotengine/godot
  15. The icons must be created in a vector graphics editor in SVG format. There are
  16. two main requirements to follow:
  17. - Icons must be 16×16. In Inkscape, you can configure the document size in
  18. **File > Document Properties**.
  19. - Lines should be snapped to pixels whenever possible to remain crisp at lower DPI.
  20. You can create a 16×16 grid in Inkscape to make this easier.
  21. Once you're satisfied with the icon's design, save the icon in the cloned
  22. repository's ``editor/icons`` folder. The icon name should match the intended
  23. name in a case-sensitive manner. For example, to create an icon for
  24. CPUParticles2D, name the file ``CPUParticles2D.svg``.
  25. Icon optimization
  26. ~~~~~~~~~~~~~~~~~
  27. Because the editor renders SVGs once at load time, they need to be small
  28. in size so they can be efficiently parsed. Editor icons must be first
  29. optimized before being added to the engine, to do so:
  30. 1. Add them to the ``engine/icons/svg`` folder.
  31. 2. Run the ``optimize.py`` script. You must have the ``scour`` package installed:
  32. .. code-block:: bash
  33. pip install scour
  34. cd godot-design/engine/icons && ./optimize.py
  35. The optimized icons will be generated in the ``engine/icons/optimized`` folder.
  36. Integrating and sharing the icons
  37. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. If you're contributing to the engine itself, you should make a pull request to
  39. add optimized icons to ``editor/icons`` in the main repository. Recompile the
  40. engine to make it pick up new icons for classes.
  41. It's also possible to create custom icons within a module. If you're creating
  42. your own module and don't plan to integrate it with Godot, you don't need to
  43. make a separate pull request for your icons to be available within the editor
  44. as they can be self-contained.
  45. For specific instructions on how to create module icons, refer to
  46. :ref:`Creating custom module icons<doc_custom_module_icons>`.
  47. Troubleshooting
  48. ~~~~~~~~~~~~~~~
  49. If icons don't appear in the editor make sure that:
  50. 1. Each icon's filename matches the naming requirement as described previously.
  51. 2. ``modules/svg`` is enabled (it should be enabled by default). Without it,
  52. icons won't appear in the editor at all.
  53. References
  54. ~~~~~~~~~~
  55. - `editor/icons <https://github.com/godotengine/godot/tree/master/editor/icons>`__