godot icon indicating copy to clipboard operation
godot copied to clipboard

[Godot 4.0] Editor Shows Error when using class_name on Script that Extends from Resource

Open arisvaldez opened this issue 3 years ago • 6 comments

Godot version

4.0.dev Beta 3

System information

Windows 10, foward_plus, Nvidia RTX 2060

Issue description

Editor displays message "Class Pepe(this case) hides a global script class", whenever saving a file with class_name.

In addition to this, when I create a resource based on this class and click to see it in the inspector, I cannot see the exported variables, even if I make a change it is not reflected in the inspector.

I am using Godot Editor

class_name_error

Steps to reproduce

Open attached project. Open my_script.gd. Save file There's an error.

Create a Resource using Pepe on Search box Double click on recent created Resource. Look at inspector, exported variable can't use from it. If I remove the class_name then all works fine

class_name_error_full

Minimal reproduction project

ClassNameOnResourceExtends.zip

arisvaldez avatar Oct 21 '22 19:10 arisvaldez

Related to https://github.com/godotengine/godot/issues/67056 (possible duplicate?).

Calinou avatar Oct 21 '22 20:10 Calinou

I am having this same issue as well in Godot 4 beta 3

Indieology avatar Nov 01 '22 12:11 Indieology

I recreated my simple project from a fresh start in Godot 4 beta 4. This issue seemed to disappear. Until I pushed a commit through github of the project. Then this error reappeared. Not entirely sure this is what caused it, but seemed to be the case. @arisvaldez was this the case with you as well?

Indieology avatar Nov 02 '22 13:11 Indieology

I recreated my simple project from a fresh start in Godot 4 beta 4. This issue seemed to disappear. Until I pushed a commit through github of the project. Then this error reappeared. Not entirely sure this is what caused it, but seemed to be the case. @arisvaldez was this the case with you as well?

you Mean Godot 4 beta 3?

@Indieology In my case this error appears every time I use the keyword class_name in a file that inherits from Resource.

every time I give save then it produces the error.

I don't use any source code in this project

arisvaldez avatar Nov 02 '22 19:11 arisvaldez

Related to #67056 (possible duplicate?).

Maybe it's the same, but in this case I added the behavior of the inspector, which happens when I try to open the resource file in Inspector

arisvaldez avatar Nov 02 '22 19:11 arisvaldez

Hi everyone!!

@Indieology , @Calinou

I have tested the project in Godot 4 beta 6 and the error has disappeared

arisvaldez avatar Nov 28 '22 02:11 arisvaldez

I can still see the error in Beta 14, any one else also having the issue? EDIT: I have a Node2D (not a Resource) that has a class_name of FooBar

andersonmadeira avatar Jan 28 '23 02:01 andersonmadeira

I can still see the error in Beta 14, any one else also having the issue? EDIT: I have a Node2D (not a Resource) that has a class_name of FooBar

greetings @andersonmadeira , I tested on RC 2 and does not launch the error

arisvaldez avatar Feb 16 '23 12:02 arisvaldez

I'm having this issue extending a Resource using class_name and get the Class Hides global script class error. In Godot 4.0.1. Just tried Godot 4.0.2, the issue is in the newest version as well. This happens when using the ResourceLoader when it pulls in the saved Resource. It seems to be loading the class_name twice (once from the save and once from the project) when it loads a saved Resource.

Further experimenting... This line: ResourceSaver.save(tmp_save, "user://save.tres", ResourceSaver.FLAG_BUNDLE_RESOURCES) causes the "hides global script class" error This line: ResourceSaver.save(tmp_save, "user://save.tres", ResourceSaver.FLAG_NONE) does not cause an error.

Why?

rabrant avatar Apr 10 '23 08:04 rabrant

I also have a lot of trouble with this issue in Godot 4.0.2. It definitely is not dependent of the extended class, I get this with MeshInstance3D and others. Sometimes it helps to delete the .Godot folder to get the project running, but closing and reopening the editor raises the error again

frankwinterdotcom avatar Apr 12 '23 16:04 frankwinterdotcom

Yep, having the same issue. Can we get this fixed please? It's really annoying and actually quite a critical bug to fix as it makes inheritance far less useful.

dev-mico avatar Jun 16 '23 15:06 dev-mico

Is there a way to bump issues to gain more traction? This is pretty critical, in my opinion. Game development relies heavily on inheritance.

dev-mico avatar Jun 16 '23 15:06 dev-mico

Same issue, only when I work on the project on a Mac.

andhedrew avatar Sep 08 '23 14:09 andhedrew