I can create a custom node by giving it a class_name, so it appears in the “Create New Node” dialog:
I can also do this by adding the script to a plugin, but that does not appear to change the behaviour at all.
But when I “Add Child Node…”, it adds a node that matches the core type that my custom node inherits from and adds my custom node script as an attached script:
Is there any way with newer versions of Godot to create a true custom node type with GDScript? I would specifically like to create one that would not need this script attached so that I can attach different scripts to each instance of the custom node in my scene.
I have been able to do this by using GDExtension with C++, but I can’t figure out how to do it with a new custom node type that is written in GDScript…
As a workaround, I can choose to “Extend Script…” after adding the custom node type to the scene. This gives me most of the functionality that I’d like, but it does make it difficult to see, at a quick glance of the scene panel, which nodes in my scene have custom scripts attached to them.
Not through GDScript, but you can extend that TestScript node which is functionaly similar to attaching a script to a GDExtension based node.
Ah your edit just mentioned this ha!
I wouldn’t worry about it much, practice naming your nodes I suppose. Use more GDExtension if you are comfortable with it. You can also assign icons to node with a GDScript by using the @icon("res://myicon.svg") annotation, but I understand that can be a lot of work.
Maybe this database will help if you go through the icon route
I guess every time I extend my custom node script, I could set the new script’s icon using @icon, as you mentioned. This would give me an indicator that I’ve extended my custom node type.
By using this add_custom_type function, the script icon in the scene dock appears greyed out and it behaves similar to any built in core node type, except that I need to “Extend Script…” instead of “Attach Script”:
When I “Extend Script…”, the grey script icon changes to a solid black icon. This is exactly the sort of functionality I was looking for!