-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class "XXX" hides global script class on FileAccess.get_var() #68666
Comments
Seems like the cause is:
So when an I guess it would make sense to marshall |
The same happens when callling |
Has anybody been working on this? Else I would like to take a look and see if I can fix this as it's a big inconvenience for my current game project. |
Please re-test in the latest master or a recent beta. PR #71142 has likely fixed this issue. |
Nope, I still get this error (I'm on RC 2) |
I just got the same error on RC 4. |
Getting this error as well currently. Cannot continue work on my project |
Still getting this error in 4.0.2, posting hacky workaround. I was able to bypass the error by making a new dummy script and class name that extends the problem class and loading objects with the dummy script attached instead. Example script: attack_resource_import_only.gd
My use case is loading a resource that contains an array of resources (a weapon resource with an array of "available attacks" resources). Nesting the attack resource within the weapon resource triggered the error but it's working by using the dummy import only resource. I can use the autocompletion of the main class (AttackResource), so not using the dummy class anywhere other than assigning it in the inspector. |
This is still happening in newly released version |
Also happening in |
Has anybody been able to come up with any work arounds? I've tried using the Edit: Using Edit 2: Some sample code: const PATH: String = "res://some_arbitrary_path.txt"
var my_object: CustomResource
func save():
var file = FileAccess.open(PATH, FileAccess.WRITE)
file.store_var(var_to_str(my_object))
file.close()
func load():
var file = FileAccess.open(PATH, FileAccess.READ)
my_object = str_to_var(file.get_var())
file.close() |
I wrote this code to convert objects to dictionaries automatically and store them using store_var (with full_objects = false), then read them back from dictionary to object. It's kind of reinventing the wheel, but may help someone until this is fixed: https://www.reddit.com/r/godot/comments/17hrj2q/sharing_my_save_state_code_not_converting_to_json/ @DispairingGoose do you know if using var_to_str / str_to_var approach will force you to export the game with gd script files not compiled (i.e. as plain text)? This question https://ask.godotengine.org/99313/save-file-breaks-after-game-export made my think it could be the case, even when var_to_str is not mentioned there :), but in my mind it would make sense that is the case. |
It seems to be the case that you don't need to export gdscript files as plain text using the following code:
Tested on 4.1.3 - I have attached the project I tested with. |
I found a temporary work around. Change the e.g.
And when you load (keeping the filename the same wasn't an issue):
Changing the filename didn't have an effect and I tried loading the project with this change and then trying to change it back and loading again to see if the cache clears but that didn't work, so this is my current work-around. |
This is still an issue and popped up again for all the new classes/ files I created after doing a linux build... so I realized that the classes are conflicting the files found in the export filter that I placed in the same directory as my project. Once I moved the export folder out to a parent directory, the issue was gone. |
Happening to me on v4.3.dev5.official [89f70e9] - Doesn't that basically makes store/get_var kind of useless? |
I tested this. It looks like after #78219 writing is done correctly:
However, when reading, a crash occurs due to the fact that the
We probably need to replace a pointer with CC @vnen |
I am still seeing this with the latest 4.3 beta when trying to FileAccess.get_var() a dictionary with a custom resource as the value. |
not fixed |
@KyleReese, @BCG-Jackson Sorry for the delay. Can't reproduce this in 4.3 with the MRPs one and two. Note that you must export the variable to be stored in a file. There is currently an inconsistency between text and binary serialization for resources, see #80894 and #80897. If your issue is still not resolved, please provide reproduction steps, MRPs, and/or other details. |
Ran into the same issue when trying to binary save scene at its current state (props, vars, nodes etc.) using var_to_bytes(true) and then trying to load it using bytes_to_var |
Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.
Godot version
v4.0.beta4.official.e6751549c
System information
Ubuntu 22.04
Issue description
GDscript produces an error with no backtrace: "Class 'XXX' hides global script class'.
I've narrowed down an error I started getting when loading saved objects from a file down to the call to
FileAccess.get_var()
. This occurs when I have a class instance written out withFileAccess.store_var(true)
(which works), and doesn't appear to occur for any other reason.I can just serialise the object myself (and probably should) but this error is definitely harder to track down with no backtrace.
Steps to reproduce
Just run the attached minimum project.
Minimal reproduction project
storavar_bug.zip
The text was updated successfully, but these errors were encountered: