Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Easy Save - The Complete Save & Load Asset for Unity

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

  1. Vince_DD

    Vince_DD

    Joined:
    Jul 15, 2014
    Posts:
    2
    Hi Joel,

    thanks for the quick reply. Looks like this only works with "GUI/Text Shader" now. That's unfortunately not an option for me, since that one doesn't work with UI masks. Is there any other way to make this work?

    I've noticed that for some reason, when you change and apply the import settings for ANY font while the game is running, all fonts suddenly render correctly. Weird.

    EDIT: Seems like this only happens with dynamic fonts. For dynamic fonts, they'll work correctly once Font.textureRebuilt is called.

    Best,
    Vincent
     
    Last edited: Feb 26, 2018
  2. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Many thanks Vincent, this is very useful.

    I've managed to find a workaround at our end which will stop this happening in the future, which I will PM to you in a moment.

    It looks like textureRebuilt is called whenever the text is rescaled, so changing the scaleFactor of the Canvas Scaler component attached to the Canvas fixes the problem for any GUI Texts which are already affected.

    All the best,
    Joel
     
  3. Blue-Wolf

    Blue-Wolf

    Joined:
    May 27, 2014
    Posts:
    13
    Hi Joel, if I may, any update on ES3's release time frame? I’m considering using it for a project but can only justify it if it’s planned for release shortly.

    Thanks in advance!
     
  4. joeltebbett

    joeltebbett

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

    We're still working through feedback from the beta, and made the decision to introduce new functionality before releasing it, so I still can't give any definite timeframe.

    However, the main functionality (except the GameObject/Prefab saving and spreadsheet functionality) currently has no outstanding bug reports, and is marked as release-ready internally.

    However, we will still be supporting Easy Save 2 at least until the end of the Unity 2017.x cycle, and almost certainly throughout the Unity 2018.x cycle (unless they make any significant changes which make backwards compatibility impossible).

    All the best,
    Joel
     
  5. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    247
    Hi @joeltebbett,

    Is there a way with ES2 to temporarily parse raw data and extract a tag without saving a file to disk? When my game loads I receive the latest save file from a server, but I don't want to overwrite local data unless I know that the server data is newer. To know whether it is newer, I need to load data from a tag within the save file to use for comparison. Ideally I'd do this without saving anything to disk as a buffer. I'm hoping I can somehow only parse a specific tag from that save file so that I don't have to parse the entire raw data. Thanks!
     
  6. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    @arlevi09

    This is indeed possible. You can use ES2Web.LoadRaw to load the downloaded data as a byte array, and then put the bytes into an ES2Reader, which you can use to read the tag. This would look something like this:

    Code (CSharp):
    1. using( ES2Reader reader = ES2Reader.Create( web.LoadRaw() , new ES2Settings()) )
    2. {
    3.     int myTimestamp = reader.Read<int>("timestamp");
    4. }
    All the best,
    Joel
     
  7. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    247
    Working great! Thanks for the fast response.
     
  8. wood333

    wood333

    Joined:
    May 9, 2015
    Posts:
    607
    Will ES3 support unity 5.6.5 ?
     
  9. jvt619

    jvt619

    Joined:
    Jul 4, 2013
    Posts:
    42
    How to turn off the automatic reference of Easy Save 3 since it would literally take 4-6 minutes to load my game when hitting the play button since I have many objects in a single scene.
     
  10. joeltebbett

    joeltebbett

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

    Apologies for the late reply, Unity did not notify me that there were new posts in this thread.

    Easy Save indeed supports 5.6.5.

    All the best,
    Joel
     
    wood333 likes this.
  11. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Apologies for the late reply, Unity did not inform me that there were new posts in this thread.

    You can turn off automatic referencing by going to Window > Easy Save 3 > Settings and deselect Auto Update References.

    All the best,
    Joel
     
  12. SweatyChair

    SweatyChair

    Joined:
    Feb 15, 2016
    Posts:
    111
    FYI, I've done a performance test for ES3 in an old Android 4.4 phone, using default ES3 settings. Here's the result if you interest:

    SaveInt x 10000 = 72.27539s, average 0.007227539s per save
    LoadInt x 10000 = 7.944637s, average 0.0007944637s per load

    SaveString x 10000 = 76.16858s, average 0.007616858s per save
    LoadString x 10000 = 8.032284s, average 0.0008032284s per load

    SaveIntList x 10000 = 77.33618s, average 0.007733618s per save
    LoadIntList x 10000 = 22.84155s, average 0.002284155s per load

    SaveIntDictionary x 10000 = 76.17188s, average 0.007617188s per save
    LoadIntDictionary x 10000 = 42.9044s, average 0.004290441s per load

    I'm happy with the result.
     
  13. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Thank-you very much for this, that's very interesting. Would you be able to post the code you used to test this? If you're not doing so already, you might also be able to improve performance using ES3File to cache the data.

    All the best,
    Joel
     
  14. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    286
    I want to ask if an user has a save file that contains:
    PlayerHealth

    And then I add one more variable in that file:
    PlayerDamage

    Would he be able to load a game using his old save file and set a default value for PlayerDamage, because I am using BinaryFormatter (with my own save-load system) and there's an exception if the users already have an existing save file and the new version of the game uses an extended save file.
     
  15. joeltebbett

    joeltebbett

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

    This is possible in Easy Save. You would simply specify the defaultValue parameter when loading. For example:

    Code (CSharp):
    1. PlayerHealth = ES3.Load<int>("PlayerHealth");
    2. PlayerDamage = ES3.Load<int>("PlayerDamage", 123);
    All the best,
    Joel
     
    skinwalker likes this.
  16. xcube

    xcube

    Joined:
    Nov 27, 2011
    Posts:
    40
    Hello,
    what settings in ES3 it is better to use for mobile devices (ios/android)?


    Please give an example of code that will save and load the texture for ios and Android.
    I'm trying. But it doesn't work for me.
    Code (CSharp):
    1. ES3.SaveImage(darawTexgture, "cube1.jpg"); // save
    2.  
    3. if(ES3.KeyExists("cube1.jpg")){ // load
    4.   darawTexgture = ES3.LoadImage("cube1.jpg");
    5. }
    Thanks!
     
  17. joeltebbett

    joeltebbett

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

    The default setting provided with Easy Save are fine for mobile.

    With regards to your code, I don't appear to be able to see in your code where you're applying the image you've loaded to the Material of a Renderer? There's an example in the Saving and Loading Images page: http://docs.moodkie.com/easy-save-3/es3-guides/saving-loading-images/

    All the best,
    Joel
     
  18. xcube

    xcube

    Joined:
    Nov 27, 2011
    Posts:
    40
    Thank you for quick reply!
    I understand it, the save works. Image loading does not work because of Key Exists. Without Key Exists, the download also works.
    Can I check if an image exists?
     
  19. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Ahh I understand. You're using ES3.KeyExists when you should be ES3.FileExists, because "cube1.jpg" is a file, not key.
     
  20. xcube

    xcube

    Joined:
    Nov 27, 2011
    Posts:
    40
    Super! Now everything works. Very convenient and high-quality asset, I gladly bought it, I will use it in all projects.
    Thanks for your support!
     
    joeltebbett likes this.
  21. Gatskop_Software

    Gatskop_Software

    Joined:
    Sep 21, 2014
    Posts:
    52
    Is there easy safe 3 playmaker examples somewhere scene's
     
  22. Mkarena

    Mkarena

    Joined:
    Oct 15, 2015
    Posts:
    4
    Hi,

    I Just bought the asset but i'm struggling to make this simple code working:

    Code (CSharp):
    1.         Dictionary<GameType, int> dico = new Dictionary<GameType, int>
    2.         {
    3.             {GameType.Calcul, 10}
    4.         };
    5.  
    6.         ES3.Save<Dictionary<GameType, int>>("dico", dico);
    7.         Debug.Log(ES3.Load<Dictionary<GameType, int>>("dico")[GameType.Calcul]);
    It returns me this error:

    ArgumentException: not of type: GameType
    Parameter name: key

    Thanks for help
     
    hajimamad likes this.
  23. joeltebbett

    joeltebbett

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

    I don't appear to be getting the error you're getting. Please could you send me a self-contained script which replicates it? Or you can PM me a link to a very basic project if this is easier. I've tried replicating it with the following script:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class DictTest : MonoBehaviour
    6. {
    7.     void Start ()
    8.     {
    9.         Dictionary<GameType, int> dico = new Dictionary<GameType, int>
    10.         {
    11.             {GameType.Calcul, 10}
    12.         };
    13.  
    14.         ES3.Save<Dictionary<GameType, int>>("dico", dico);
    15.         Debug.Log(ES3.Load<Dictionary<GameType, int>>("dico")[GameType.Calcul]);
    16.     }
    17. }
    18.  
    19. public struct GameType
    20. {
    21.     public int myInt;
    22.     public static GameType Calcul = new GameType(1);
    23.  
    24.     public GameType(int myInt){ this.myInt = myInt; }
    25. }
    All the best,
    Joel
     
    Last edited: May 31, 2018
  24. Gatskop_Software

    Gatskop_Software

    Joined:
    Sep 21, 2014
    Posts:
    52
    How can I save a string array to cloud in Easy Save 3 with playmaker ? Please help
     
  25. cygnusprojects

    cygnusprojects

    Joined:
    Mar 13, 2011
    Posts:
    642
    Could be he doesn't get notified by the Unity forum software. Happens from time to time. Maybe contact him using this form: https://moodkie.com/contact/
     
  26. e-sollinger

    e-sollinger

    Joined:
    Dec 30, 2016
    Posts:
    11
    Joel,
    We need to know if the ES3 can read in the ES2 files. I understand that they are not compatible, together, but we have versions where the files were written using ES2, and will need to be loaded with the new ES3 version if we are going to upgrade the software.

    We are needing to do the upgrade only because we hope that you have addressed a 33MB file limit we are now seeing in the ES2 dll during one of its IOStream calls where the capacity of the stream was limited to 33MB. Please let us know if you were aware of this issue, else I will provide more info.
     
    Last edited: Jun 12, 2018
  27. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Apologies for the late reply, we were indeed not notified of new posts in this thread. It looks like you've taken cygnusprojects advice and contacted us directly, which I've replied to.

    All the best,
    Joel
     
  28. joeltebbett

    joeltebbett

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

    Easy Save imposes no limits on Stream sizes. If you email me a basic project and instructions to replicate this, I'll try to see what's happening (I've replied to the email you sent me).

    All the best,
    Joel
     
  29. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    Sorry for noob question but what is this in the below pic?
    I just start using this asset.

    I'm going to create a big database for a website created by unity3d! Can I make this .txt file more clean?
    Does it work with webgl and html?
     

    Attached Files:

    Last edited: Jul 24, 2018
  30. joeltebbett

    joeltebbett

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

    Easy Save 2 saves data in binary format. If you require a human-readable format, you should use Easy Save 3 which uses JSON formatting. Alternatively if you don't need serialised data and simply want to upload your own strings, you can use ES2.SaveRaw to save a raw string to a file.

    Easy Save indeed works with WebGL (it uses PlayerPrefs as the storage location when storing locally). I'm unsure what you mean regarding it working with HTML however?

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

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    So that's mean I can't create a database of usernames and passwords because WebGl uses PlayerPrefs and can't store in a txt file? :(
     
  32. joeltebbett

    joeltebbett

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

    I'm not sure what you mean by creating a database? If you want to get the save data to put into your own database, you can get the data as a raw string using ES2.LoadRaw or ES3.LoadRawString.

    Just to clarify, WebGL doesn't allow you to create files on the user's file system for security reasons. This is a limitation of WebGL in general.

    All the best,
    Joel
     
  33. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,001
    I don't want to create files on the user's hard drive I just want to create a txt file in my server so I can save usernames and password in that file. What I'm talking about is a txt file that saves string values in a server where the game is uploaded.
     
  34. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    ksam2 likes this.
  35. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    19
    Hey, I'm having exactly the same exception when loading. GameType is a simple Enum, not a struct or whatever.

    public enum GameType
    {
    Game1,
    Game2
    }
     
  36. joeltebbett

    joeltebbett

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

    Please could you post a script which replicates this, or PM me a project which replicates it?

    Please also ensure you are using the latest update from the Asset Store.

    All the best,
    Joel
     
  37. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    19
    Here you go, a simple demo created in 2018.2
     
  38. joeltebbett

    joeltebbett

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

    Please could you delete the attachment from your post? Otherwise you're publically sharing Easy Save, which is against Unity's terms of service and license agreement.

    I've downloaded it and am currently looking into it.

    All the best,
    Joel
     
  39. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    19
    Oops, sorry, didn't realize that! Done.
     
  40. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Thanks for doing that, much appreciated.

    It looks like the fix for this bug didn't make it to the latest version on the Asset Store. If you PM me your invoice number, I'll PM you over a package which will fix this.

    All the best,
    Joel
     
  41. Alberto-Zamora

    Alberto-Zamora

    Joined:
    Jul 26, 2017
    Posts:
    3
    The Playmaker Create File action don't create a file.

    Here is my invoice number: IN-----

    How to write and load anything from a custom file?
     
    Last edited: Aug 3, 2018
  42. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    485
    Hi there, and sorry to hear that you have been encountering problems.

    To create a file, you use the Save actions (see the Save Actions section). These actions create a file if it does not already exist, and save data to it. By default files are created in Unity's Application.persistentDataPath, which is the only place which guaranteed to exist and be writable at runtime.

    You can then use the Load actions to save data from a file you've saved to, using the same Key as you used to write the data.

    I've created two basic examples for you here which highlight how you could use the actions in a project:
    Saving and Loading a Variable using PlayMaker
    Saving and Loading a Transform using PlayMaker

    Note that you will need PlayMaker and Easy Save installed in your project before importing the example. The example can be found in Assets/Easy Save 3/Examples/ after importing.

    Hope this helps!

    Also you may want to remove your invoice number from your post, as this is not safe to post publicly.

    All the best,
    Joel
     
  43. SwingWren

    SwingWren

    Joined:
    Mar 1, 2014
    Posts:
    3
    Hello, just recently I bought the plugin and I'm still trying it out.

    I'm using ES3 and I had to stop adding the easy save manager to my game scenes as it corrupts the guid of some of the elements in the scene. The load and save of data I'm doing still works so my question is:

    What parts of the plugin will not work without the manager?

    thanks,
    Marcel
     
  44. joeltebbett

    joeltebbett

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

    The manager controls the Auto Save functionality, and the ability to save prefab instances and references.

    All the best,
    Joel
     
  45. glucosetong

    glucosetong

    Joined:
    Aug 10, 2017
    Posts:
    2
    Hello,

    I am trying to add custom types to easy save. I am able to find my classes in es2 type manager but not in es3. My code are written under a namespace. Does it matter? Also, can I save runtime instantiated objects and a reference list to those objects?

    thanks,
    Glucose
     
  46. joeltebbett

    joeltebbett

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

    It should work regardless of the namespace your type is in. The search bar is case sensitive. Are you typing the typename into the search bar in the correct case?

    If so, please could you send me a type which replicates this, and let me know what you're typing into the search bar?

    With regards to saving instantiated objects, please see the Saving and Loading Prefab Instances section of this guide. Easy Save can indeed save a reference list to those objects.

    All the best,
    Joel
     
  47. glucosetong

    glucosetong

    Joined:
    Aug 10, 2017
    Posts:
    2
    Hi Joel,

    Thank you for your reply. I didn't notice es3 is case sensitive. I can find my class right now :D But I still don' get the right behavior of the reference list. The code is as below:

    Code (CSharp):
    1. public class myclass : MonoBehaviour {
    2.    
    3.     public GameObject cube;
    4.    
    5.     public List<GameObject> test1 = new List<GameObject>();
    6.     public List<GameObject> test2 = new List<GameObject>();
    7.  
    8.     //button
    9.     public void AddCube()
    10.     {
    11.         GameObject go1 = (GameObject)Instantiate(cube, new Vector3(0, 0, 0), Quaternion.identity, this.gameObject.transform);
    12.         GameObject go2 = (GameObject)Instantiate(cube, new Vector3(0, 0, 0), Quaternion.identity, this.gameObject.transform);
    13.         GameObject go3 = (GameObject)Instantiate(cube, new Vector3(0, 0, 0), Quaternion.identity, this.gameObject.transform);
    14.         test1.Add(go1);
    15.         test1.Add(go2);
    16.         test2.Add(go2);
    17.         test2.Add(go3);
    18.         ES3.Save<List<GameObject>>("myGameObjects", test1);
    19.         ES3.Save<List<GameObject>>("myGameObjectss", test2);
    20.     }
    21.  
    22.     //button
    23.     public void Load()
    24.     {      
    25.         ES3.Load<List<GameObject>>("myGameObjects", test1);
    26.         ES3.Load<List<GameObject>>("myGameObjectss", test2);
    27.     }
    28. }
    In my game, I am using a brain to keep track of the objects' behavior and process the operation. There are some tracking lists which are overlapped. When I am trying to load back the scene, there are 4 cubes instead of 3 cubes which test1 and test2 point to different go2. Is there any other way to get around this? I am trying to instantiate the objects explicitly to load. But I still don't know how to get back the reference. Do I need to save id explicitly?

    thanks,
    Glucose
     
  48. joeltebbett

    joeltebbett

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

    It seems this is an issue at our end. If you PM me your invoice number, I'll send you an update which fixes this.

    All the best,
    Joel
     
  49. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    286
    Hello,

    I have a question, first let me explain you how my current loading system works. I have one game object with DontDestroyOnLoad called NpcDataContainer, it has a List of NpcData and there I have every npc in my game with a different Id depending on the current scene (because one npc can exist in multiple scenes). I load the data into that container and then every NPC looks up that container, finds the right ID and loads its data. The way I fill the container with data is very simple, but I cannot check if the variable exists because of the BinaryFormatter (it will throw an error), so I switched to ES and want to have the same system but using ES, I am confused how to set it up because of the "tags", currently this is how I fill the container with data from the saved file:

    Code (CSharp):
    1.         private void LoadDataIntoContainer(string filePath, string fileName)
    2.         {
    3.             if (File.Exists(filePath + "/" + fileName + ".dat"))
    4.             {
    5.                 BinaryFormatter bf = new BinaryFormatter();
    6.                 FileStream file = File.Open(filePath + "/" + fileName + ".dat", FileMode.Open);
    7.  
    8.                 NpcDataContainer npcDataContainerGo =  GetComponent<NpcDataContainer>();
    9.                 NpcDataSerializable npcExportDataSerializable = (NpcDataSerializable)bf.Deserialize(file);
    10.                 file.Close();
    11.  
    12.                 for (int i = 0; i < npcDataContainerGo.NpcData.Count; i++)
    13.                 {
    14.                     var savedDataTarget =
    15.                         npcExportDataSerializable.NpcExportData.FirstOrDefault(n =>
    16.                             n.Id.Equals(npcDataContainerGo.NpcData[i].Id));
    17.  
    18.                     if (savedDataTarget == null)
    19.                     {
    20.                         Debug.LogWarning(npcDataContainerGo.NpcData[i].Id + " does not exist in the save file");
    21.                         continue;
    22.                     }
    23.  
    24.                     npcDataContainerGo.NpcData[i] = savedDataTarget;
    25.                 }
    26.  
    27.             }
    28.         }
    I would be good if you have any suggestions.
     
  50. joeltebbett

    joeltebbett

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

    I'm not certain what you're trying to achieve. However, in Easy Save, to save your container you would simply do:

    Code (CSharp):
    1. ES3.Save<NpcDataContainer>("key", GetComponent<NpcDataContainer>(), filePath + "/" + fileName + ".dat");
    And then to load it:

    Code (CSharp):
    1. // If no save data exists, do nothing.
    2. if(!ES3.FileExists(filePath + "/" + fileName + ".dat")) return;
    3.  
    4. // Load the data from the file into your NpcDataContainer object.
    5. ES3.LoadInto<NpcDataContainer>("key", filePath + "/" + fileName + ".dat", GetComponent<NpcDataContainer>());
    All the best,
    Joel