godotengine / godotengine/godot
Custom resources with built-in scripts cannot be assigned to typed variables in the inspector
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Reproducible in: 4.3.stable.mono
### System information
Windows 11
### Issue description
Custom resources using built-in GDScript scripts display unexpected behavior in the Inspector. An `@export` variable of type `MyCustomResource`, `Array[MyCustomResource]`, and so on should allow all .tres files that extend that class to be added to the array. However, if the file's script is built-in it will not be accepted even if the built-in script extends MyCustomResource. If the variable is `Array[Resource]`, though, it will be accepted.
### Steps to reproduce
- Create a custom resource with a `class_name` of your choosing (such as `MyCustomResource`).
- Create another object with an `@export var my_var : MyCustomResource`.
_- Create a .tres of MyCustomResource in the FileSystem. This file can be assigned to `my_var` without issue and demonstrates the expected behavior._
- Create another Resource file and view in the Inspector. Right-click on its script slot and choose _New GDScript_ to create a script built-in to the .tres file.
- Add `extends MyCustomResource` to the top of the built-in script and save.
- This cannot be added to my_var in the Inspector.
It should be noted that writing `my_var : Resource`, adding the built-in-script-resource to it, then changing `my_var:MyCustomResource` seems to keep the built-in-script-resource's assignment, it just prevents actually assigning it in the Inspector
### Minimal reproduction project (MRP)
(None)
Contributor guide
Research direction
Start with the Inspector assignment behavior described in the reproduction steps, comparing typed MyCustomResource variables with Resource variables and built-in scripts. Done means a built-in script extending MyCustomResource can be assigned to the typed Inspector variable, including typed arrays, while preserving the existing Resource behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100