Loading Issue using ScriptableObjects

Discussion and help for Easy Save 3
Post Reply
Zhorky
Posts: 3
Joined: Mon Feb 25, 2019 9:27 pm

Loading Issue using ScriptableObjects

Post by Zhorky »

Hello.

Im currently playing around with serializing a SaveGame Scriptable Object and syncing it to cloud.
I save by using

Code: Select all

ES3.Save<SaveData>("save",Save);
ES3.CreateBackup("save.dat");
SaveData is my ScriptableObject i want to save. This works as planned and everything seems to be wonderful (even cloudsave works like a charm... even though my mysql was installed on latin and not utf8 which created some issues at first.)

Loading errors out for me with following message:
InvalidOperationException: Trying to load data of type SaveGame, but data contained in file is type of SaveData.
ES3Reader.ReadTypeFromHeader[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:273)...
I load by following code:

Code: Select all

local = ES3.Load<SaveGame>("save");
cloudLoad(local);
cloudLoad(local) compares the local save with the cloud save and replaces it if needed and writes it to the 'Save' variable.

At first i didn't know that i had to add the type manually, because saving worked fine even without the type. So i got the error again -> Added the type -> Still got the error.


Furthermore i have 2 questions:
#1:
Is there a way to save raw json without using the ES3 serializer and maybe just use saving+encryption of ES3? (JsonDotNet serializes and deserializes custom structures fairly well and i would love to use it in combination)

#2:
Speaking of encryption: I get an error on every start telling me
CryptographicException: Bad PKCS7 padding. Invalid length 0.
Im unsure what this tells me. I just know that my encryption key is NOT 0 long. It's 12 with numbers, upper and lowercase characters and special characters.



Would be nice if i could get a hint in the right direction :)
Thanks for your help.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Issue using ScriptableObjects

Post by Joel »

Hi there,

With regards to your first issue, you're saving your data using ES3.Save<SaveData>, but you're loading it using ES3.Load<SaveGame>.

You can save raw strings (such as JSON) using ES3.SaveRaw, and load it using ES3.LoadRawString.

With regards to the bad padding error you are getting, this will most likely be because:
  • You're loading unencrypted data with encryption enabled
  • You're using a different password than was used when the data was encrypted
  • The data has become corrupted, perhaps by previous errors
  • You have an Auto Save component in your scene which is trying to load from an encrypted file created using code rather than Auto Save
Could you show me the code you're using to save and load? Also please could you tell me where you enabled encryption? Or if you could create a new project which replicates the error and PM it to me, that would be even better.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Zhorky
Posts: 3
Joined: Mon Feb 25, 2019 9:27 pm

Re: Loading Issue using ScriptableObjects

Post by Zhorky »

Thanks for the quick support Joel.

The Data and Game issue were too obvious :roll:
I disabled auto saves/auto load and the padding error disappeared.

Another issue appeared while testing further.
Savefiles get encrypted correctly, but they are unencrypted on the server.
The usernames get encrypted though
So the User 123456 turns into "|J� �7b�a� �=�d���".
Either this issue exists due to my change to UTF8_general_ci in the database or it's another layer 8 error and i am the one to blame.

Loading the user 123456 works fine though.
It would be really nice if i could get the savegame of a user just by doing a quick sql query like

Code: Select all

SELECT * FROM `es3cloud` WHERE user = "123456";
Greetings and thanks for the great support again.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Issue using ScriptableObjects

Post by Joel »

Hi there,

Would you be able to tell me a bit more about how you determined that they were unencrypted on the server?

Also would you be able to share with me the code you're using to save the data, and to upload it to the server?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Zhorky
Posts: 3
Joined: Mon Feb 25, 2019 9:27 pm

Re: Loading Issue using ScriptableObjects

Post by Zhorky »

For sure
Here is my save script.
https://pastesafe.net/d9MaaFlrDY

I discovered the unencrypted data in phpmyadmin by downloading and opening the BLOB file.
I only did this because i wondered about the weird username which should have been "123456"
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Issue using ScriptableObjects

Post by Joel »

Are you certain that the save file that gets uploaded is encrypted? All the upload does is upload the contents of the local file to the server. It doesn't perform any encryption or decryption of the file, so it's unusual that it's appearing decrypted.

Would you be able to create a new, basic project which replicates it and PM it to me?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply