Search Unity

Easy Save - The Complete Save Data & Serialization Asset

Discussion in 'Assets and Asset Store' started by JoelAtMoodkie, May 28, 2011.

  1. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Hello again,

    Once I load a File in the cache:

    var settings = new ES3Settings(ES3.Location.Resources);
    settings.path = "vars.bytes";
    ES3.CacheFile(settings);

    1. It works nicely, but if I make changes to the vars.bytes and then try to re-load the cache as per above, it does not have the changes it only remembers the initial cache load,
    Is there a way to 'clear' the cache and reload a file?


    2. During runtime if i make changes to the cache and use ES3.StoreCachedFile();
    Should it not automatically save to the file it loaded from? If not do i always have to specify its settings to the resources as above? Where exactly does it store the cached file then, if i wanted to load it on next run?

    Just trying to wrap my head around the resources file, as it seems I cannot make changes or save on it inside the successor folder "
    NotSupportedException: Deleting files from Resources is not supported.
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation."

    3. Can I load multiple files into cache?
     
    Last edited: May 30, 2021
  2. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    If I understand you correctly, the issue is that you can't modify Resources at runtime because Unity complies these into the project. For more information please see the Resources guide:
    https://docs.moodkie.com/easy-save-3/es3-guides/saving-loading-resources/

    ES3.StoreCachedFile() will store to the default file in the default storage location. You can either provide your settings to the ES3.StoreCachedFile(string path, ES3Settings settings) method, or you can change the default settings in Tools > Easy Save 3 > Settings.

    This happens for the same reason explained in my answer to your first question. Resources cannot be modified at runtime because Unity complies them into the executable.

    You can. The cache methods accept a filename/path and ES3Settings object and you can call the methods for a specific file.

    All the best,
    Joel
     
  3. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thank you for the clarification
     
  4. IggyZuk

    IggyZuk

    Joined:
    Jan 17, 2015
    Posts:
    43
    Since updating to the new version of ES3, I've started getting an error when calling:

    Code (CSharp):
    1. ES3.KeyExists("SomeKey");
    For some reason the data that gets saved looks like this:

    Code (CSharp):
    1. {
    2.     null : {
    3.         null : null,
    4.         null : null
    5.     }
    6. }
    Tried deleting the save file from Persistent Data Path, doesn't help.

    Any pointers would be helpful, thanks.
     
  5. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    I've managed to replicate this at my end. I'll push an update to resolve this, but in the meantime if you private message me your invoice number I'll send over the update.

    All the best,
    Joel
     
    Last edited: Jun 1, 2021
  6. Techno-Valley

    Techno-Valley

    Joined:
    Jun 24, 2018
    Posts:
    27
    I've used Easy Save 3 for my game currently in Progress.
    The support and bugs fixes were great.
    I've face some errors but I manage to override.
    I'm posting a preview video for the Save and Load function
     
    JoelAtMoodkie likes this.
  7. Techno-Valley

    Techno-Valley

    Joined:
    Jun 24, 2018
    Posts:
    27
    I'm facing a recurrent error while using the asset.
    When I switch from one scene to another (Main Menu Scene to Level 1 Scene) I get the following error:

    Code (CSharp):
    1. ArgumentNullException: Argument cannot be null.
    2. Parameter name: key
    3. System.Collections.Generic.Dictionary`2[UnityEngine.Object,System.Int64].set_Item (UnityEngine.Object key, Int64 value) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:155)
    4. ES3Internal.ES3ReferenceMgrBase.Add (UnityEngine.Object obj, Int64 id) (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:253)
    5. ES3Internal.ES3ReferenceMgrBase.Merge (ES3Internal.ES3ReferenceMgrBase otherMgr) (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:127)
    6. ES3Internal.ES3ReferenceMgrBase.Awake () (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:105)
    7.  
    No sure why
     
  8. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Hey there. I found using Save/Load Playmaker actions work as excepted, though I'm having issues using the SaveAll/LoadAll of the local variables in an FSM. As a test I opened an empty scene, fresh FSM, added 2 int values then made an event to SaveAll and then LoadAll. When trying to LoadAll I get the following error.

    GameObject : FSM : State 2 : LoadAll : System.FormatException: Expected '{' or "null", found '0'.


    The "Key" string in both my SaveAll and LoadAll actions are named "test_save"

    My SaveFile looks like this
    {
    "test_save" : {
    "__type" : "ES3PlayMaker.PMDataWrapper,Assembly-CSharp-firstpass",
    "value" : {
    "objs" : {"test_int1":0,"test_int2":0
    },
    "arrays" : {
    },
    "obj" : null,
    "array" : null
    }
    }
    }

    I tried clearing Persistent Path Data. I'm on Unity 2020.1.11 and the latest version EasySave. Any ideas what this might be?
     
    Last edited: Jun 13, 2021
  9. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    If updating Easy Save doesn't resolve the issue, please could you private message me a basic project which replicates this with instructions?

    All the best,
    Joel
     
  10. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    We've had another report of this and will be issuing a fix in the upcoming update. In the meantime if you private message me your invoice number I'll send over the update.

    All the best,
    Joel
     
  11. Dobalina

    Dobalina

    Joined:
    Sep 6, 2013
    Posts:
    105
    Hey Joel, thanks for the follow up! I have one more question. Looking at the example below, if I wanted to load only the "profile_name" string value using playmaker, do I have to use the LoadAll action to access it? Seeing as I only want to load one value from the SaveFile, I tried using the "Load" action with the key set to "profile_name" but it didn't return any string value.


    {
    "slot0" : {
    "__type" : "ES3PlayMaker.PMDataWrapper,Assembly-CSharp-firstpass",
    "value" : {
    "objs" : {"distance_traveled":{
    "__type" : "int"0
    },"ammo":{
    "__type" : "int"0
    },"health":{
    "__type" : "int"0
    },"profile_name":{
    "__type" : "string""example_name"
    }
    },
    "arrays" : {
    },
    "obj" : null,
    "array" : null
    }
    }
    }
     
    Last edited: Jun 13, 2021
  12. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    That is correct, data saved with Save All needs to be loaded with Load All, because Save All saves to a structure which tells Easy Save which piece of data relates to each PlayMaker variable, and the type of data it should be loaded as.

    All the best,
    Joel
     
    Dobalina likes this.
  13. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Hello,

    During runtime I create a new spreadsheet: ES3Spreadsheet siteSpreadsheet = new ES3Spreadsheet();
    Eventually I do: siteSpreadsheet.Save("SiteReading.csv", settings);

    Once I am done with the spreadsheet how do I close it? Because I'd like to re-run the code and save it again,

    Currently if I re-run my code I get this error:
    IOException: Sharing violation on path ...SiteReading.csv

    Even though its recreated?

    Thanks
     
  14. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    We've had no reports of this. Please could you replicate this in a new, empty project with a simple scene using the latest version of Easy Save and private message it to me with instructions.

    All the best,
    Joel
     
  15. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Seems like I had preventative measures in place in my script:
    if(ES3.FileExists("SiteReading.csv", settings)) ES3.DeleteDirectory("SiteReading.csv", settings); // start fresh!
    But instead of ES3.DeleteFile i had directory... so after changing that it works

    I tried replicating this error in a blank project, cant seem to be able to. I'm using a third party plugin that uses the created file as an attachment to send via email, perhaps that's the issue?
     
  16. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    This could potentially be the issue, but it wouldn't be possible for me to tell for certain.

    All the best,
    Joel
     
  17. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Yes it seems like I run into that issue when I am sending the email as an attachment, and if I try re-sending the same email as is, I'm assuming the email still has the excel cached or something? It gives me the error Sharing violation for trying to ES3.DeleteFile before re-creating a new one,
    What would be my work around? I'm trying to think of a way to re-produce this in a blank project with the email send...
    Or is there a way to check if file is still open, to clear everything within and fill it out as usual?

    First I create the file then I send the email:

    upload_2021-7-2_15-55-6.png
     
  18. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    As the issue will be caused by the email asset rather than at our end, I'm afraid I can't provide assistance. However, it's likely to be because the email asset is accessing the file asynchronously, or it's failing to close it's FileStream.

    All the best,
    Joel
     
  19. hamzanassiim

    hamzanassiim

    Joined:
    Apr 25, 2019
    Posts:
    4
    Hi, Im facing this error whenever i try to save and load.
    Code (CSharp):
    1. FormatException: Expected ',' separating properties or '"' before property name, found 'n'.
     
  20. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Have you tried updating Easy Save from the Asset Store and deleting your save data (Tools > Easy Save 3 > Clear Persistent Data Path)?

    All the best,
    Joel
     
  21. hamzanassiim

    hamzanassiim

    Joined:
    Apr 25, 2019
    Posts:
    4

    Im using v3.3.2f4 and yeh i tried to delete saved data from (Tools > Easy Save 3 > Clear Persistent Data Path)
     
  22. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    3.3.2f5 is the latest version. Other reports of this issue were resolved in that version, so updating from the Asset Store should resolve it.

    All the best,
    Joel
     
  23. hamzanassiim

    hamzanassiim

    Joined:
    Apr 25, 2019
    Posts:
    4

    Thanks joel!
     
  24. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    Hello.

    First, thank you for a nice asset.
    Now I have a question. Is it possible with Easy Save to make a multi saving slots/points and then loading them. I am still kinda new in Unity and also programming. With ES3 every saving point is saved named SaveFile.es3 or however you name this file in settings in ES3 menu "Default File Path". But I cant figure it out if there is a way to make this from a single slot to a multi slots. Also cant find answer to this on any forum or in docs.

    PS: sorry for bad english xD

    Tom
     
  25. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Easy Save methods contain a filePath parameter. Please see the Getting Started guide for more information:
    https://docs.moodkie.com/easy-save-3/getting-started/#changing-the-filename-or-path

    All the best,
    Joel
     
    heh223 likes this.
  26. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    Wow, thanks a lot Joel! Now I have mutli slots saving system. :D

    Tom
     
    CrandellWS likes this.
  27. Techno-Valley

    Techno-Valley

    Joined:
    Jun 24, 2018
    Posts:
    27
    I guess I'm able to regenerate error.
    When I have two separate scenes. (My case here one scene for Main Menu and another scene for the level)
    Each scene has Easy Save Manager. (Is that correct ? Shall I use two easy save scene managers in both scenes ??)
    Knowing that save and load functions are in level scenes. and load function exists only in Main Menu scene.

    I've got a similar error but with different context.

    Code (CSharp):
    1. ArgumentNullException: Value cannot be null.
    2. Parameter name: key
    3. System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
    4. System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (TKey key, TValue value) (at <e1a80661d61443feb3dbdaac88eeb776>:0)
    5. ES3Internal.ES3ReferenceMgrBase.Add (UnityEngine.Object obj, System.Int64 id) (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:253)
     
  28. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    It's necessary to have an Easy Save 3 Manager in each scene where you're saving references.

    Regarding your error, please could you replicate this in a new, empty project with the latest version of Easy Save using a simple scene and private message it to me with instructions.

    All the best,
    Joel
     
  29. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    I updated to the last version but I can't load previous save files anymore! seems It saves differently now my previous save file was like;
    {"BB":{"___type":"system.object,mscorlip"."value":{"___type":"system.string""BB"}}}

    and now it saves like this

    "BB" : {
    "__type" : "string"
    "value" : "BB"
    }

    Do I need to save all my saves again?
     
  30. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    This was an issue in 3.3.2.f5 but was resolved in 3.3.2f6. Are you sure you are using the latest version? You can find this out by going to Assets/Plugins/Easy Save 3/Change Log/.

    All the best,
    Joel
     
    ksam2 likes this.
  31. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    I
    Yes it was f5 but I revert back to my previous backup because there was another issue that I couldn't load arrays that was created and saved using Playmaker. Is this fixed in f6 too?
     
  32. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Correct.

    All the best,
    Joel
     
    ksam2 likes this.
  33. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    Hello,

    I can't really find a solution to save a destroyed object in my project. I have few gameobject (keys, locks) which are destroyed after I pick or unlock them. All I want is that these gameobject are destroyed after I load a saved game. Is there any easy way to do this? They are not instantiated.

    Tom
     
  34. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Please find attached a script which you can attach to a GameObject to manage this.

    All the best,
    Joel
     

    Attached Files:

  35. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    This script is confusing me a bit. I'm still not that good at coding, so I will need a bit more help. In my project I have a multi-slot saving system. Saved game files are named mySave1.es3, mySave2.es3... but destroyed objects are saved automatically in a separate file as SaveFile.es3. So if I load a new game or a game from a saved file, all previous destroyed objects are now destroyed. Can you please help me with this. I do believe it is not hard but for me it still kinda is.

    Ty
     
  36. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    You should just be able to attach the script to the GameObject you want to store the destroyed state of. If you want it to save to a specific filename, simply provide a filename in the ES3.Save and ES3.Load methods as described in the Getting Started guide.

    All the best,
    Joel
     
  37. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    I have my saving/loading system done, but now I have a little problem. How to make a loading system work from the main menu which is in a different scene. In the save/load scene I have public variables to every gameobject that has to be saved but I don't know how to access them from different scenes. Is it even possible?
     
  38. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    I'm afraid it's unclear what you mean by "work from the main menu". Please could you clarify?

    All the best,
    Joel
     
  39. heh223

    heh223

    Joined:
    Jan 2, 2020
    Posts:
    25
    I can load saved games when I'm in a game scene. But can't load a saved game from the main menu. The main menu is a different scene. The problem is that all gameobjects that need to be saved are declared in a script as public variables and these gameobject don't exist in the main menu scene so I can't access them. I also added a screenshots.
    mainmenu ES3.png
    game ES3.jpg

    PS: sorry for my bad english xD
     
  40. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    This wouldn't be possible because a reference to these objects will not exist in that scene, unless they're prefabs instantiated at runtime (in which case you would follow the Saving and Loading Prefab Instances instructions here).

    Generally in this case when the player presses the load button it would set the default filename to the file for that save slot, and then it would open the Game scene (i.e. the scene where you saved your data). Then when the Game scene opens, it would load the data using that default filename.

    All the best,
    Joel
     
  41. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    Hey
    I have a question about how to save a MonoBehaviour script in my test scene.

    What I have:
    I have an object in my scene called "itemObject" and on this object there's an script called "itemScript". "itemScript" derives from MonoBehaviour and contains some variables about the item data. The "itemScript" of every object is stored in a list in my "environmentScript".

    What I want:
    I want to save the list of "itemScripts" and the data of the "itemScripts" in my "environmentScript". After loading the list I create a new "itemObject" and add the "itemScript" with its data.

    I know I can't just save the "itemScript" because it derives from MonoBehaviour...

    Is there a smart way to do that?

    Thank you in advance for your answers.
     
  42. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    Why not? Easy Save is capable of saving objects which derive from MonoBehaviour. You could even save the list of itemScripts.

    All the best,
    Joel
     
  43. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    I think I'm doing something wrong...

    When I store an "itemScript" in the list, quit the application and start it again it loads an empty entry ("none" in editor).
    I also can't add a "itemScript" manually if it isn't added to an "itemObject".

    I think I just can't have a MonoBehaviour script that's not a component of a GameObject or what is needed to implement this?
     
  44. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    I’m not sure I understand. In Unity it’s not possible for a MonoBehaviour to exist without a GameObject to attach it to.

    Please could you create a new script which replicates your issue which I can drop into a new scene and send it to me with step-by-step instructions.

    All the best,
    Joel
     
  45. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    Well that answers my question already because that's what I tried... (save the MonoBehaviour script without the GameObject)
    I wanted to save the MonoBehaviour script just like a class that isn't deriving from MonoBehaviour.

    In that case I have to save the GameObjectg and that should work fine I guess.

    Thank you for your help!
     
  46. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    I'm not sure what's preventing you from doing this. For example, you should be able to do this:

    Code (CSharp):
    1. // To save
    2. ES3.Save<ItemScript>("itemScript", itemScript);
    3. // To load
    4. itemScript = ES3.Load<ItemScript>("itemScript");
    All the best,
    Joel
     
  47. RiseBasti

    RiseBasti

    Joined:
    Nov 4, 2018
    Posts:
    33
    Hi Joel

    Until now i just used the auto save function in ES3 but at this point I really have to change that. (And it's so easy to code it!)

    I had some struggle to get it how it works (because i thought i have to create the GO by my self) but now i see it creates an GO automatically. Smart! ;)

    Thank you so much and have a nice day.
     
    JoelAtMoodkie likes this.
  48. JamesXyXz

    JamesXyXz

    Joined:
    Aug 2, 2021
    Posts:
    12
    Easy Save doesn't save sliderMouseSensitivity.value. Is this a bug?
     
  49. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    Hi there,

    “sliderMouseSensitivity” doesn’t appear to be a variable which appears in the Unity API, so I am unable to comment.

    For information on what classes are explicitly supported, and what types of data will be saved on classes which are not explicitly supported, please see the Supported Types guide:

    https://docs.moodkie.com/easy-save-3/es3-supported-types/

    All the best,
    Joel
     
  50. JamesXyXz

    JamesXyXz

    Joined:
    Aug 2, 2021
    Posts:
    12
    What does "Save GamObject Child" do in Auto Save? I can't find it in your documentation.