Hmm okay this is weird. What happens when you remove the type from the array?
I removed the type hints on both array and the error still presists
But theres no error when the resource extends CardEffect instead of EffectMove?
1 Like
This similar issue suggests to clear the cache and restart the engine, because the cache might be corrupted:
opened 01:22AM - 28 Jan 23 UTC
closed 11:53AM - 17 Feb 23 UTC
bug
topic:gdscript
### Godot version
Godot 4.0 Beta 16
### System information
Win10
###… Issue description
Hello! This is my first bug submission, apologies if it's a bit rough.
I noticed a change in behaviour regarding export vars of a custom resource type. In Beta 14 and prior, you're able to specify an export var of a _parent_ custom resource type, then give it a value of a _child_ resource type that inherits from the parent type. (Basic inheritance, pretty much.) I've verified this on Beta 10.
As of Beta 15, which introduced a change to how custom resource loading works, and added the ability to quick load custom resources, export vars of custom resources seem to no longer respect inheritance. I've tested this on Beta 16, but the change itself was introduced in Beta 15, so it should be the same behaviour.
I've attached a minimal reproduction project that demonstrates the new (bugged) behaviour.
Please let me know if you need any more info, or if I've made a mistake somewhere! Thanks for all the work on the project!
### Steps to reproduce
1. Create a custom resource that extends from Resource ("FirstResource").
2. Create a second resource that extends from the first one ("SecondResource").
3. Create an instance of SecondResource.
4. Create an export var of type FirstResource on a node.
5. Instantiate that node in a scene.
6. Restart Godot, since it's fussy about newly created resource types.
7. Try and load your instance of SecondResource onto the node's FirstResource property.
8. Observe the type error (e.g. _The selected resource (SecondResource) does not match any type expected for this property (FirstResource)._).
### Minimal reproduction project
[CustomResourceInheritanceDemo.zip](https://github.com/godotengine/godot/files/10524227/CustomResourceInheritanceDemo.zip)
So delete the .godot folder and start the engine again. Maybe do a backup of the folder, eventhough that shouldnt be neccessary. Note that this will lead to the engine having to reimport all the assets which might take a bit, depending on the number of assets
1 Like
calador
August 15, 2024, 10:56pm
26
Thanks for the idea.
Sadly it still doesn’t work.
hm okay. Inside the .godot folder is a “global_script_class_cache.cfg”-file. Open it and look for your EfffectMove-class
I came into this problem too, I removed the type definition in array( like this in your code:
@export var cards: Array[CardResource] = []
// I changed it into this
@export var cards: Array = []
and it works
hope this can help you