+2 votes

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.

asked Feb 22, 2019 in Engine by avencherus (4,815 points)

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

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.

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.

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.

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 https://github.com/godotengine/godot/issues/8814

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

Please log in or register to answer this question.

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.