Hi all!
I'm having issues exporting resources inside resources with C#. ItemResource exports WeaponResource but the WeaponResource is always null even though the WeaponResource is assigned in the inspector. I tried adding the constructors like they were done in the godot documentation here https://docs.godotengine.org/en/stable/tutorials/scripting/resources.html . Also tried with just empty constructor as well. So far nothing seems to help. Im pretty new to Godot but based on the documentation, it should be possible to reference Resources inside Resource so not sure where the issue is. Any idea on this?
ItemResource.cs
`public partial class ItemResource : Resource
{
//Removed extra exports and getters for clarity
[Export]
protected WeaponResource weaponResource;
public WeaponResource WeaponResource => weaponResource;
public ItemResource() : this(null, ...other args)
{
}
public ItemResource(Resource weaponResource, ...other args)
{
this.weaponResource = weaponResource;
}
}`
WeaponResource.cs
`public partial class WeaponResource : Resource
{
[Export]
private float fireRate;
[Export]
private int magazineSize;
[Export]
private PackedScene[] projectiles;
public float FireRate { get => fireRate; }
public int MagazineSize { get => magazineSize; }
public PackedScene[] Projectiles => projectiles;
public WeaponResource() : this(1, 1, null)
{
}
public WeaponResource(float fireRate, int magSize, PackedScene[] projectiles)
{
this.fireRate = fireRate;
this.magazineSize = magSize;
this.projectiles = projectiles;
}
}
`