How to prevent 'abstract' class from showing up in resource picker?

Godot Version

4.3

Question

I’m attempting to make a series of resources extending from “Shape”, where Shape actually shouldn’t do anything. So I have classes like Circle, and Capsule that extend from shape.

When I export a Shape variable though, in the inspector a “New Shape” option appears in the dropdown when selecting it. This is the ‘abstract’ class and therefore shouldn’t really be able to be selected.

Is there any way I can prevent this? Thanks :slight_smile:

1 Like

In the normal godot engine (not gdextension) its not possible to make classes abstract

I know, which is why I put abstract in quotes - I am just treating it as such and was wondering if there was any way of hiding it in the inspector dropdown.

It’s ok in C#. Just don’t annotate your class with [GlobalClass].

public abstract partial class Shape : Resource { ... }

or just use interface like this:

public interface IShape
{
    public float Area { get; }
    public IShape Union(IShape shape);
}

[GlobalClass]
public partial class Circle : Resource, IShape { ... }