Open Geequlim opened 7 years ago
Related to #6533?
In fact the ConfigFile
doesn't requires the GDScript module.
So it would be better if inst2dict
and dict2inst
could be seprated from GDScript language and make them virtual with different script languages.
Edited
If the inst2dict
and dict2inst
become a common used functions then we can use them to serialize/unserialize script instances everywhere in the same way.
@Geequlim Can you still reproduce this bug in Godot 3.2.1 or 3.2.2beta4?
Still reproducible in 3.2.3 RC 1.
This is still reproducible on 4.3 stable.
What I noticed is even the properties of SubClass
are properly stored in the config file, the problem seems to be that because SubClass
is an inner class Godot is not able to properly "identify" the object script and due to that the SubClass
type. So when the object is loaded from the file, the properties are filled with the values from the file, but not the type.
I tried to see if I was able to identify an issue in VariantWriter
and VariantParser
which are the classes that ConfigFile
uses to serialize data, but due to my lack of knowledge on the relation between Object
and scripts I couldn't.
What I found is a way to get it working: making subObj
typed. That let Godot set the type properly and everything works as expected.
MyClass.gd
should be:
var name = "boy"
var age = 2
var subObj:SubClass = SubClass.new()
var anotherObj = preload("AnothorClass.gd").new()
class SubClass:
var sex = "male"
Operating system or device - Godot version: Godot 3.0 alpha1 on Windows 10
Issue description:
There is a class named
MyClass.gd
. Instance of this class can be save and load back withConfigFile
but something wrong with the membersubObj
which is an Instance of the inner classSubClass
.Steps to reproduce:
MyClass
withConfigFile
Link to minimal example project: ConfigFileBug.zip