Inherited resources don't work

Godot Version

4.3

Question

Hello everyone, I’m having a problem with my project. I am working with C# scripts. I have an EnemyType class that inherits from Resource. In this class, there is an array property of PickupResources. The PickupResource class also inherits from Resource, but I have a Gem class that inherits from PickupResource and, in the future, there will be other types of pickups. The problem is that when I create the EnemyType resource in Godot to set the properties in the inspector, when I try to assign a Gem resource to the PickupResource property, it gives an error saying it is not the same type of object, even though Gem inherits from PickupResource. However, if I create a resource based directly on the PickupResource class, it works, and I can assign it to my EnemyType resource.

Does anyone know how I can solve this issue?





type or paste code here

I don’t know if this will fix the issue, but I think you have to use Godot.Collections.Array for exporting:

[Export]
public Godot.Collections.Array<PickupResource> Array { get; set; }
2 Likes

Thanks, dude! Works like a charm!