+3 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 :)

in Engine by (97 points)
edited by

2 Answers

+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.

by (110 points)
selected by

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

+2 votes

To set a custom icon of a custom class:

extends Node
class_name MyClass, "res://icons/my_class_icon.svg"
by (211 points)
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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.