How to give C++ nodes editor icons?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By avencherus

Been digging through the source, but haven’t quite found anything clearly that indicates how the generated SVGs get assigned to editor nodes.

Anyone know of any examples on how to do this or where the root of this lies?

There are a lot of set_icon() and get_icon() and I’ve hit some dead ends with them.

I think they are generated by using the class name directly, so if you define Sprite3D, it will lookup for an icon named icon_sprite_3d.svg

Zylann | 2019-02-22 13:57

I’m not sure what you mean by defining. A macro definition, or something else?

Currently I’ve done something like this in a node’s header.

#include "scene/2d/node_2d.h"

class MyNode : public Node2D {
	GDCLASS(MyNode, Node2D);

When I add this node in the Editor it has the white icon of a Node and not Node2D.

avencherus | 2019-02-23 06:10

So you registered a class named MyNode: try to add an icon to the editor, which you name icon_my_node.svg. Just drop it in the icons folder, compile and see if that works for your class.

Zylann | 2019-02-23 11:44

It’s implicit by class name?

How would you go about reusing the existing icons? Do you have to copy and rename them?

I’m trying to create a module, so I don’t want to modify anything in the repo outside the module’s directory.

avencherus | 2019-02-25 04:18

Gridmap is a module, yet its icon is not in its folder ¯\(ツ)
I once opened an issue about this for documentation, which apparently was solved somehow, but the same issue exists for icons and is still a thing Cannot add icons to a module without forking Godot · Issue #8814 · godotengine/godot · GitHub

Zylann | 2019-02-25 19:25

I see. I suppose I’ll leave them as is for now.

avencherus | 2019-02-26 08:30