0 votes

The instructions for adding a custom node type to the "Create New Node" dialogue as explained in the "Making Plugins" tutorial is very straight forward. However, I'm having difficulty finding how to add a new "folder" of custom nodes to the dialogue. That is, in the list of nodes, under Node, there is a grouping of nodes called CanvasItem which is not selectable as a node, but is just a "folder" containing other nodes (and more "folders"). Unfortunately, none of the methods listed in the EditorPlugin's documentation seems to stand out as being the correct option either. How can I create such a node "folder"? Thank you!

asked Apr 3, 2018 in Engine by shianiawhite (94 points)

1 Answer

+1 vote
Best answer

That "folder" is a node type that is parent to other node types. The reason it can't be instantiated is that it is abstract. As far as I know GDscript does not support abstract classes, so you'll have to either create a non-abstract base class or add the abstract base class from the C++ backend (which would require a custom module or a PR that officially adds it to the engine).

In any case you should be sure that a base class is what you need. If you think of it as a "folder" you may be on the wrong track.

answered Apr 4, 2018 by Warlaan (1,114 points)
selected Apr 4, 2018 by shianiawhite

I see! I had thought the organization structure was separate from inheritance since in my custom node I specify the node type it's extending (extends ExistingNode), but then I have to separately place it in the node list using the plugin's class that extends EditorPlugin. This is done using add_custom_type("MyNode", "ExistingNode", preload("my_node.gd"), preload("my_node.png")). So even though you need to explicitly set the parent in the node list in when using add_custom_type, it can only be set to the node it's inheriting from? I would think this would mean that the second parameter should be removed from add_custom_type then (unless I'm missing something).

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.