I use static typing in my project and I like to create reusable components.
When I want to add a component to an object, I often create a new node of my class instead of instantiating the scene by accident.
Is there a way to exclude custom nodes with class names from the “Create new Node dialog” so I can’t make this mistake anymore?
@tool
class_name VisionComponent
extends Area2D
## don't add this class to the "create new node" menu
@anon45973056 I think you have it. I guess the next logical step would be to assign it to the editor profile… But I don’t see a way to do that
I was going to say idk, but maybe to enhance the script call. You could make a static func _static_init(): Godot should call this automatically whenever your class is first used.
The other option would be to remove the class_name. But I assume you use that in script to create it or reference static variables?
I think the only drawback is that you may want to use in other scenes you just don’t want two in a single scene?
If that is the case I don’t see an easy way around it…
Maybe you could somehow default to a disabled state and you could utilize the visibility as an indication? So if you accidentally created a new one it would be disabled and hidden.
After some testing is possible to use the EditorFeatureProfile to disable custom classes but re-importing it is not exposed for scripting (as far as I can tell).
Thankfully the .profile files are just JSON files that you can edit and import manually.
This JSON disables a custom class called VerticalLabel.
Just add whatever classes you want to hide in the disabled_classes array, save the file as a .profile file, and import it in the Editor -> Manage Editor Features... dialog. The name of the file will be the name of the profile.