Nested save
Posted: Tue Jun 25, 2019 12:36 am
Hello! Earlier, I used asset just to save elementary types. Everything was OK.
Now I am trying to create a nested save:
-Character
--Name
--Health
--List <ItemController>
---ItemManager
----Id
----CurItem
----Items
---ItemManager
----Id
----CurItem
----Items
I load and save the Character with the help of LoadInto and Save accordingly.
For it, an EC3Type i'm automatically created with all the specified fields. There are no problems with the name and health.
I also created the EU3Type for ItemController with id and name.
But only it's _ES3Ref is saved!
I tried to manually change ReadComponent / WriteComponent (in Character)
Then the save works.
But nothing is being loaded...
I made such a code and it all worked, but now I’m not at all sure that I’m doing everything correctly =\
Now I am trying to create a nested save:
-Character
--Name
--Health
--List <ItemController>
---ItemManager
----Id
----CurItem
----Items
---ItemManager
----Id
----CurItem
----Items
I load and save the Character with the help of LoadInto and Save accordingly.
For it, an EC3Type i'm automatically created with all the specified fields. There are no problems with the name and health.
I also created the EU3Type for ItemController with id and name.
But only it's _ES3Ref is saved!
Code: Select all
"ItemManagers":[{"_ES3Ref":724151928669719713},{"_ES3Ref":1934583549284300375},{"_ES3Ref":1923890871494309969},{"_ES3Ref":4583309440906128168}]
Code: Select all
foreach (var itemManager in instance.ItemManagers)
{
writer.Write<ItemManager>(itemManager.id, itemManager);
}
Code: Select all
foreach (var itemManager in instance.ItemManagers)
{
if (itemManager.id == propertyName)
{
reader.ReadInto<ItemManager>(itemManager);
}
}
Code: Select all
"Hair":{"__type":"ItemManager,Assembly-CSharp","value":{"_ES3Ref":724151928669719713,"_ES3Ref":724151928669719713,"goID":7320055566608279791,"id":"Hair","currentItem":null,"boughtItems":[],"currentColor":{"r":1,"g":1,"b":1,"a":1}}}
Code: Select all
foreach (var itemManager in instance.ItemManagers)
{
if (itemManager.id == propertyName)
{
reader.ReadInto(itemManager.id, itemManager);
}
}