There is no "Assets/Easy Save 3/Types/", only "Assets/Easy Save 3/Scripts/Types/". I imagine that's not the one you need.
I think my main questions are:
1. I was not expecting ES3 touching files that I'm not directly saving, and I'm assuming is touching the file because a variable is being discarded on Load (I probably just don't understand how it really works).
2. Why would this happen with one object but not another object of the same kind (specially if the variable is being set on the inspector). I attached a video showing that.
The variable that is being discarded is "ContainerType" on the Ceramic Container. Coconut Container works fine. (I was able to reproduce this in a small project if that's helpful)
This is the .es3 save file
Code: Select all
{
"ItemDatabase" : {
"__type" : "System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[IItem, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]],mscorlib",
"value" : {"Ceramic Container":{
"__type" : "PortableContainer,Assembly-CSharp",
"_ES3Ref" : "7106626596454675402",
"_ES3Ref" : "7106626596454675402",
"resourceToHold" : null,
"containerType" : {
"_ES3Ref" : "8130308086468330343"
},
"itemTitle" : "Ceramic Container"
},"Coconut Container":{
"__type" : "PortableContainer,Assembly-CSharp",
"_ES3Ref" : "8459430624397898974",
"_ES3Ref" : "8459430624397898974",
"resourceToHold" : {
"_ES3Ref" : "7280631713494607686"
},
"containerType" : {
"_ES3Ref" : "878180826301136058"
},
"itemTitle" : "Coconut Container"
}
}
}
}
Code: Select all
public class ItemDatabase : MonoBehaviour
{
#pragma warning disable 649
[SerializeField] Item[] items;
#pragma warning restore 649
public static Dictionary<string, IItem> ItemDictionary { get; private set; }
private void Awake()
{
CreateItemDatabase();
}
private void Update()
{
if (Input.GetKeyUp(KeyCode.S))
{
SaveDatabaseWithNewItems();
}
if (Input.GetKeyUp(KeyCode.L))
{
Load();
}
}
private void CreateItemDatabase()
{
ItemDictionary = new Dictionary<string, IItem>();
int counter = items.Length;
for (int i = 0; i < counter; i++)
{
Assert.IsTrue(items[i], "Item is arriving null, probably an empty space in the array");
Assert.IsFalse(ItemDictionary.ContainsKey(items[i].ItemID), "Repeated item ID: " + items[i].ItemID + ", " + items[i].name);
ItemDictionary.Add(items[i].ItemID, items[i]);
}
Debug.Log("Dictionary created");
}
private void SaveDatabaseWithNewItems()
{
ES3.Save<Dictionary<string, IItem>>("ItemDatabase", ItemDictionary);
ItemDictionary = ES3.Load<Dictionary<string, IItem>>("ItemDatabase");
Debug.Log("Saving");
}
private void Load()
{
Debug.Log("Load Database");
ItemDictionary = ES3.Load<Dictionary<string, IItem>>("ItemDatabase");
//LoadSprites();
ItemDictionary = ES3.Load<Dictionary<string, IItem>>("ItemDatabase");
}
}