Previously in Easy Save 2 I was able to save a Texture2D directly to a file using ES2.Save<Texture2D>.
I just got around to converting this old code to Easy Save 3 and everything works except saving and loading the Texture2D.
I use ES3File now to cache my data, so using ES3File.Save<Texture2D> doesn't fail or throw an error, but when checking the file, it seems to have saved nothing. The JSON entry is completely blank. Simple code to test this below.
Code: Select all
[Header("Original")]
public Texture2D picture;
public string data1 = "This is data1";
public int data2 = 0202383;
[Header("Load Testing")]
public Texture2D picture_load=null;
public string data1_load = "";
public int data2_load = ;
/// <summary>
/// Will update the local file with the data.
/// </summary>
void UpdateFile()
{
ES3File FileToUpdate = new ES3File("File.es3");
FileToUpdate.Save<string>("Data-1", data1);
FileToUpdate.Save<int>("Data-2", data2);
FileToUpdate.Save<Texture2D>("Picture", picture);
FileToUpdate.Sync();
}
/// <summary>
/// Will load the data from a local file.
/// </summary>
void LoadFile()
{
ES3File FileLoad = new ES3File("File.es3");
picture_load = FileLoad.Load<Texture2D>("Picture"); //Returns nothing, KeyExist is true because the key is in the file, but no data exists for the file.
data1_load = FileLoad.Load<string>("Data-1"); //Returns fine
data2_load = FileLoad.Load<int>("Data-2"); //Returns fine
}
Thanks.