Not saving custom class components
Posted: Sat May 15, 2021 10:12 pm
Hi,
I'm new to easysave so may be missing something obvious but when I add a custom script to a game object and save it, nothing about the script is saved.
I made a new test scene with ES3 manager.
I have tried changing settings for Save Gameobject Children and serialize by Ref And Value but no difference.
I create an empty game object, attach my custom script.
Then click a button to fire off this code:
It works, I get a new save file for each gameobject in the list, the contents however are only showing native Unity gameobject values and structure.
It will show child objects etc, but nothing about any custom scripts.
I have searched the forums and documentation and don't see anything obvious about this and feel like I must be missing something obvious since custom scripts will be on pretty much everything in a game.
One example of my empty GO save file:
The goal I'm after is the player creates a new combination of gameobjects and components based on prefabs and customizable settings, which I then want to save as a blueprint and destroy the original from the in-game scene. Then later the player can load blueprints back into any scene or game session.
The blueprint object will be much more complicated than my empty test above, but I'm just trying to prove the basic concept works first.
The custom class derives from mono behaviour and contains native public fields like strings and booleans.
I'm new to easysave so may be missing something obvious but when I add a custom script to a game object and save it, nothing about the script is saved.
I made a new test scene with ES3 manager.
I have tried changing settings for Save Gameobject Children and serialize by Ref And Value but no difference.
I create an empty game object, attach my custom script.
Then click a button to fire off this code:
Code: Select all
for (int i = 0; i < this.ObjectsToSave.Count; i++)
{
this.saveNames.Add(System.Guid.NewGuid().ToString() + ".json");
ES3.Save(this.saveNames[i], this.ObjectsToSave[i], this.saveNames[i]);
}
It will show child objects etc, but nothing about any custom scripts.
I have searched the forums and documentation and don't see anything obvious about this and feel like I must be missing something obvious since custom scripts will be on pretty much everything in a game.
One example of my empty GO save file:
Code: Select all
{
"b48d835f-9896-4e47-bb8a-4c6af22f5dd7.json" : {
"__type" : "GameObject",
"value" : {
"_ES3Ref" : "6705505823549809242",
"transformID" : 1077788400736667770,
"layer" : 0,
"tag" : "Untagged",
"name" : "LG_GameObject",
"hideFlags" : 0,
"active" : true,
"children" : [
],
"components" : [
{
"__type" : "Transform",
"_ES3Ref" : "1077788400736667770",
"goID" : "6705505823549809242",
"parent" : null,
"localPosition" : {
"x" : 80,
"y" : 416,
"z" : 0
},
"localRotation" : {
"x" : 0,
"y" : 0,
"z" : 0,
"w" : 1
},
"localScale" : {
"x" : 1,
"y" : 1,
"z" : 1
}
}
]
}
}
}
The blueprint object will be much more complicated than my empty test above, but I'm just trying to prove the basic concept works first.
The custom class derives from mono behaviour and contains native public fields like strings and booleans.