+2 votes

Hello,

I'm currently working on the look&feel of this extension: https://github.com/djiamnot/gdosc.

Is there an "official" procedure to add an icon to the editor for a custom module, without modifying the editor itself?

For the moment, i found a way to do so:

  • create an icon_[my custom class].svg in the folder "editor/icons" (requires the source of the engine)
  • recompile the engine
  • restart the engine: if the naming is correct, icon should be displayed in the menu

Naming convention seems to be: suffix any capital with an "_" character. For the class i'm working on, named *OSCtransmitter*, the filename must be:

  • icon_ (prefix)
  • osctransmitter > o_ -> O, s_ -> S & ctransmitter -> Ctransmitter,
  • .png (extension...)

enter image description here

The result is cool, but i'm certan it is not the right way of doing... Any advice or example would be welcomed :)

asked Mar 15, 2018 in Engine by frankiezafe (86 points)
edited Mar 15, 2018 by frankiezafe

1 Answer

+1 vote
Best answer

Doubt there's a proper way to do this: in the main engine, even the visual script module just has them in editor/icons and I can't see any "proper" way. It just pulls it from the editor icons theme type. So since you're making a full blown module instead of using say GDNative (on that note, unless GDNative is too restrictive for your module, using it might be better than a regular module), editor/icons is probably the best way.

If you want to hack it (arguably harder) you could try getting a hold of the editor theme and setting an icon override for the whole editor with Theme.set_icon("OSCtransmitter", "EditorIcons", texture) but keep in mind you'll have to export the SVG manually (the SVGs are exported in Godot's build process, which won't work if you go this way).

PS: when making a regular plugin with GDNative/GDScript/etc the icon is added in the EditorPlugin::add_custom_type call as documented here.

answered Mar 18, 2018 by Pieter-Jan Briers (110 points)
selected Mar 20, 2018 by frankiezafe

Thanks for the response, the GDNative approach seems much cleaner than the hacker way :) - I will certainly try this.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.