Can't add custom node type when it extends from abstract class

Godot Version

Godot 4.2.2

Question

I want to add a new custom type, this custom type has to extend from CollisionObject2D

I’ve created a new plugin, these are the files created
plugin.cfg

[plugin]

name="CoolAreaPlugin"
description=""
author=""
version=""
script="coolareaplugin.gd"

coolareaplugin.gd

@tool
extends EditorPlugin


func _enter_tree():
	add_custom_type("CoolArea2D", "CollisionObject2D", preload("cool_area_2d.gd"), preload("res://icon.svg"))


func _exit_tree():
	remove_custom_type("CoolArea2D")

cool_area_2d.gd

@tool
extends CollisionObject2D

# Called when the node enters the scene tree for the first time.
func _ready():
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

However no matter what I do the node doesn’t appear in the list why is this?

I’m not 100% sure this is what you’re trying to achieve, but I believe what your looking for is class_name.

@tool
extends CollisionObject2D
class_name Your_Class_Name

This will enable you to search the class name in the list(of classes).
It’ll also allow you to easily access the class in other nodes, as it makes the class name global.

Not sure if I’m doing something wrong but it still does not appear in the list

I’ll attach some pictures in case I’m doing something wrong

The setup



The result:

Did you try reloading the current project? Tool scripts have to be reloaded to work properly.

I didn’t but now I tried and it doesn’t work either. However if I extend from Node instead of CollisionObject2D (basically a non-abstract node) it works. So i guess it is not possible to do what I want?

EDIT: Not sure if related. But I just created a simple script (no plugin) named beep.gd and with the following content

extends Node
class_name Beep

and it does in fact appear in the node tree when adding a node

However if I change Node for any abstract node class, it doesn’t work, as if I couldn’t instantiate them because they inherit from an abstract class

This might be a bug. Through further testing I found out that using BaseButton as base class does indeed allow the custom node type to appear. So maybe it’s just CollisionObject2D?