godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.17k stars 21.2k forks source link

Editor: Issues with inner classes and the resource picker #70991

Open vonagam opened 1 year ago

vonagam commented 1 year ago

Godot version

master

System information

MacOS 10.15.7

Issue description

67614 added checks into create dialog and resource picker. Checks for create dialog were fixed as they were reported in #69889. But resource picker still has same problems "Cannot get class".

Steps to reproduce

extends Node

class MyResource extends Resource: pass

@export var my_resource: MyResource = null

Create a single node and attach this script. Select node and get errors about getting class. This is an example with resource as nested class, but another case is MyResource is another non-global script that is preloaded.

Minimal reproduction project

N/A

YuriSizov commented 1 year ago

I guess https://github.com/godotengine/godot/pull/77911 would fix this.

HolonProduction commented 1 year ago

I guess #77911 would fix this.

The case of preloaded scripts is addressed by it. Inner classes won't work and I'm not sure whether they should. From the docs:

Beware that resource files (.tres/.res) will store the path of the script they use in the file. When loaded, they will fetch and load this script as an extension of their type. This means that trying to assign a subclass, i.e. an inner class of a script (such as using the class keyword in GDScript) won't work. Godot will not serialize the custom properties on the script subclass properly.

But the error message could maybe be changed to something more meaningfull like Cannot get class. Are you using an inner class?.