godot: Error when setting exported custom resource field to be a new resource
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
4.0.beta2
System information
Ubuntu 20.04
Issue description
When attempting to set the value of an exported custom resource field of type TestResource
(extending Resource
) by using the “New TestResource” option through the editor, the following error is emitted:
Failed to set a resource of the type 'Resource' because this EditorResourcePicker only accepts 'TestResource' and its derivatives.
Steps to reproduce
- Create a custom resource with class name
TestResource
extendingResource
with a single exported field.
extends Resource
class_name TestResource
@export var field := ''
- Create a custom node type with class name
TestNode
extendingNode
with a single exported field of typeTestResource
.
extends Node
class_name TestNode
@export var node: TestResource
- Create a node of type
TestNode
. - Click on the created node. The
Node
field should be<empty>
. - Try to set the
Node
field using the “New TestResource” option. The observed error will be emitted.
Minimal reproduction project
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 18
- Comments: 19 (3 by maintainers)
Why is this closed? Just happened to me in Godot 4.2 on Mac M1
This issue still exists as of Godot 4.2.1 on Ubuntu 22.04.
I’m not getting the error, but the exported variable is always null for me, even though it has a Resource assigned to it in the scene:
(I’m using version 4.2.beta3 -> Inspector with the Custom Resource assigned to the exported variable:
-> Remote view of the same Node with the exported variable null:
This is what worked for me. Resource
_init
must have default values for all parameters. Then instantiate resource on export: