Search Unity

Easy Save - The Complete Save & Load Asset for Unity

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

  1. joeltebbett

    joeltebbett

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

    It's not possible for me to understand what is happening from what you've sent. Would you be able to create a self-contained script which I can drop into a scene at my end to test what is happening?

    All the best,
    Joel
     
  2. skcai

    skcai

    Joined:
    Oct 8, 2019
    Posts:
    14
    Hi,I try to replicate the problem,But it go the right color。Anyway it's good news to me :)
    Thanks so much!
     
  3. skcai

    skcai

    Joined:
    Oct 8, 2019
    Posts:
    14
    Hi,
    Here is my script.Thanks for your patience!
     

    Attached Files:

  4. joeltebbett

    joeltebbett

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

    In Step 1 you mention un-commenting the code to create your Dictionary. However, nowhere in your code does this dictionary get saved. Would you be able to open up your save file after performing this step and ensure that the correct data is in there? You can do this by going to Window > Easy Save 3 > Tools > Open Persistent Data Path, and opening the file in a text editor.

    All the best,
    Joel
     
  5. skcai

    skcai

    Joined:
    Oct 8, 2019
    Posts:
    14
    Hi,I am sure that I got the correct file at step1.

    upload_2020-1-18_18-5-25.png upload_2020-1-18_18-6-23.png
    When I set dictionary where ID =2101 value=10
    upload_2020-1-18_18-9-1.png

    I think it would be saved ,but the value is still 30.
     
  6. joeltebbett

    joeltebbett

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

    Please can you remove the attachment from this post, as you are publicly sharing the Easy Save package which is against the license agreement. In the future please private message projects to me.

    With regards to your first issue, please could you show me exactly what you're doing to create the save file? Uncommenting your code does not create the save file for me.

    With regards to your black text issue, the text appears to be white for me? Are there any steps I need to follow? Also it doesn't appear that you're using the latest version of Easy Save. Please could you try reinstalling from the Asset Store, as the black text issue was a known issue in an earlier version.

    You might also want to try using a newer version of Unity in case it's an issue with the particular version of Unity 2018 you are using.

    All the best,
    Joel
     
  7. skcai

    skcai

    Joined:
    Oct 8, 2019
    Posts:
    14
    Sorry,I have removed it .
    And will update new version file and new unity version.
    I can never thank you enough for your help!
     
  8. SwingWren

    SwingWren

    Joined:
    Mar 1, 2014
    Posts:
    9
    Hello! I'm getting and encryption error in some mac devices:

    Code (CSharp):
    1. Managed Stack Trace:
    2.  
    3. Mono.Security.Cryptography.SymmetricTransform.ThrowBadPaddingException (System.Security.Cryptography.PaddingMode padding, System.Int32 length, System.Int32 position) (at <567df3e0919241ba98db88bec4c6696f>:0)
    4. Mono.Security.Cryptography.SymmetricTransform.FinalDecrypt (System.Byte[] inputBuffer, System.Int32 inputOffset, System.Int32 inputCount) (at <567df3e0919241ba98db88bec4c6696f>:0)
    5. Mono.Security.Cryptography.SymmetricTransform.TransformFinalBlock (System.Byte[] inputBuffer, System.Int32 inputOffset, System.Int32 inputCount) (at <567df3e0919241ba98db88bec4c6696f>:0)
    6. System.Security.Cryptography.CryptoStream.FlushFinalBlock () (at <567df3e0919241ba98db88bec4c6696f>:0)
    7. System.Security.Cryptography.CryptoStream.Dispose (System.Boolean disposing) (at <567df3e0919241ba98db88bec4c6696f>:0)
    8. System.IO.Stream.Close () (at <567df3e0919241ba98db88bec4c6696f>:0)
    9. System.IO.Stream.Dispose () (at <567df3e0919241ba98db88bec4c6696f>:0)
    10. ES3Internal.AESEncryptionAlgorithm.Decrypt (System.IO.Stream input, System.IO.Stream output, System.String password, System.Int32 bufferSize) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    11. ES3Internal.UnbufferedCryptoStream..ctor (System.IO.Stream stream, System.Boolean isReadStream, System.String password, System.Int32 bufferSize, ES3Internal.EncryptionAlgorithm alg) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    12. (wrapper remoting-invoke-with-check) ES3Internal.UnbufferedCryptoStream..ctor(System.IO.Stream,bool,string,int,ES3Internal.EncryptionAlgorithm)
    13. ES3Internal.ES3Stream.CreateStream (System.IO.Stream stream, ES3Settings settings, ES3Internal.ES3FileMode fileMode) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    14. ES3Internal.ES3Stream.CreateStream (ES3Settings settings, ES3Internal.ES3FileMode fileMode) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    15. ES3Reader.Create (ES3Settings settings) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    16. ES3File..ctor (ES3Settings settings, System.Boolean syncWithFile) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    17. ES3File..ctor (ES3Settings settings) (at <42d1b56150b2432eb540e637036cbb3a>:0)
    18.  
    19.  
    What could be the issue?
     
  9. joeltebbett

    joeltebbett

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

    The most common causes of this exception is:

    • Encryption is enabled, but the file you're saving to/loading from isn't encrypted. To check this you can use ES3.LoadRawString to load the file as a string and output it to console. If the output isn't a garbled mess, the file isn't encrypted .
    • The encryption password differs from that used to encrypt it.
    • The file has been modified or tampered with.

    Hope this helps.

    All the best,
    Joel
     
  10. GabrielAguiarProductions

    GabrielAguiarProductions

    Joined:
    Aug 29, 2017
    Posts:
    6
    Hey there,

    So I imported the Easy Save to my project. And the biggest problem I have is that I can't turn off Auto Add Manager to Scene. I keep getting this error:

    ArgumentNullException: Value cannot be null.
    Parameter name: target
    ES3Editor.SettingsWindow.OnGUI () (at Assets/Plugins/Easy Save 3/Editor/SettingsWindow.cs:73)
    ES3Editor.ES3Window.OnGUI () (at Assets/Plugins/Easy Save 3/Editor/ES3Window.cs:101)


    And as soon as I open the Settings Tab of the ES3 Window it gets super slow.
    Tested on Unity 2019.3.0f3 and Unity 2019.3.0f6. Here's a video to better illustrate what's happening.

    https://www.dropbox.com/s/pkahveu1easz3tk/ES3_SettingsLagAndError_2019.3.0f6.mp4?dl=0


    Thanks!
     
    Last edited: Jan 30, 2020
  11. SwingWren

    SwingWren

    Joined:
    Mar 1, 2014
    Posts:
    9
    Thanks! found the problem, it seems that a crash in the save made it to leave it in an inconsistent state
     
  12. joeltebbett

    joeltebbett

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

    We’re aware of this and will be resolved in the upcoming update.

    In the meantime if you PM me your invoice number I can send you the update.

    All the best,
    Joel
     
  13. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    530
    Glad that’s working for you now.

    All the best,
    Joel
     
  14. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    246
    Hi @joeltebbett

    Could you please help? I am not sure if I am doing this correctly. But I am trying to create keys in a save file. But Unity returns a red error telling me the "key00" save does not exist.

    Code (CSharp):
    1. void Awake()
    2. {
    3.         _es3SaveFile = new ES3File(_savePath + "config.sav");
    4.  
    5.          if (!_es3SaveFile.KeyExists("key00"))
    6.          {
    7.                _es3SaveFile.Save<bool>("key00",  key = false);
    8.           }
    9. }
     
  15. joeltebbett

    joeltebbett

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

    Are you calling ES3File.Sync at any point to store the contents of the ES3File back to a file in storage?

    I've used the following code to replicate it and it appears to work fine. The first time I run the code it outputs false, and the second time it outputs true.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class SaveES3FileKey : MonoBehaviour
    4. {
    5.     ES3File _es3SaveFile;
    6.     bool key = true;
    7.  
    8.     void Awake()
    9.     {
    10.         _es3SaveFile = new ES3File("config.sav");
    11.  
    12.         if (!_es3SaveFile.KeyExists("key00"))
    13.         {
    14.             _es3SaveFile.Save<bool>("key00", key = false);
    15.             _es3SaveFile.Sync();
    16.         }
    17.  
    18.         Debug.Log(key);
    19.     }
    20. }
    All the best,
    Joel
     
  16. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    246

    Sync was it!! Thanks so much o_O
     
    joeltebbett likes this.
  17. Ophtalmic

    Ophtalmic

    Joined:
    Jan 19, 2015
    Posts:
    11
    Hi, i want to create scriptable object and save variables in runtime. Example;

    • I have button for create arrow building.
    • I create arrow prefab(clone) with scriptable object. And make autosave prefab. After autosave, all prefab clones created right in every scene.
    • Arrow building have a some types. Like; building level, damage rate, damage value etc.. all variables are int type.
    1. I try to save the scriptable object variables but when i start again game scene, all building variables are the same values.
    2. How can i create seperated scriptable objects or seperated, saved variables at runtime?
    Anyone have any suggestions? Thanks.
     
    Last edited: Feb 17, 2020
  18. joeltebbett

    joeltebbett

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

    I'm assuming your ScriptableObjects are stored as fields in scripts attached to your GameObject? Because ScriptableObjects are reference types, they will typically be stored by reference.

    Firstly, if you haven't done so already, go to Window > Easy Save 3 > Types, search for the script which contains your ScriptableObject field (it's case sensitive), and then press Create ES3Type Script. This will ensure that the script is stored.

    Then to ensure the ScriptableObject is stored by value, go to Assets/Easy Save 3/Types, open ES3Type_<your type name>.cs. In the WriteComponent method you'll see a line where it writes your ScriptableObject field which looks like this:

    Code (CSharp):
    1. writer.WritePropertyByRef("so", instance.so);
    Remove the "ByRef" part of the method name so that it looks like this:

    Code (CSharp):
    1. writer.WriteProperty("so", instance.so);
    This will now store your ScriptableObject by value.

    I'm afraid I don't understand the question. Would you be able to rephrase it?

    All the best,
    Joel
     
    Ophtalmic likes this.
  19. Ophtalmic

    Ophtalmic

    Joined:
    Jan 19, 2015
    Posts:
    11
    Yes you understand right Joel, "ES3Type" is the my answer. Thanks for reply, sorry for complicated question. My brain is freezing sometimes when i work too hard. I left a little feedback on store page.
     
    Last edited: Feb 17, 2020
    joeltebbett likes this.
  20. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    21
    Hi,

    I am experimenting with Easy Save 3 for a small project and I struggle to perform simple saving and autosaving.
    When I load my save after restarting the app (or reentering playmode), it looks half broken. The materials of supposedly saved objects are pink, and not all object and prefab are loaded, sometimes they're just not there anymore.
    But loading works fine when I call it for the first time and when I haven't closed the app or exit playmode yet.

    Can anywone help me with this? Is it a known problem?

    I am using Unity 2019.3.1f1

    Thanks :)
     
  21. joeltebbett

    joeltebbett

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

    Because it is working until you leave the scene, this is almost definitely because the reference to the objects/Materials changes between loads, meaning it can no longer load the reference.

    Just to check, have you followed the Saving and Loading Prefab Instances instructions here?: https://docs.moodkie.com/easy-save-3/es3-guides/saving-loading-gameobjects-prefabs/

    All the best,
    Joel
     
  22. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    21
    Thanks for your response.

    Would there be a solution for this?

    I have, as well as the auto saving instructions.
     
  23. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    21
    Oh and here is my code for saving and loading (from UI buttons)

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine.SceneManagement;
    4. using UnityEngine;
    5.  
    6. public class GameData : MonoBehaviour
    7. {
    8.     public string dataPath;
    9.     ES3AutoSaveMgr autoSaveMgr;
    10.  
    11.     public int creatures;
    12.     public int objects;
    13.     public bool desktop;
    14.  
    15.     public GameObject savedObj;
    16.  
    17.     private void Start()
    18.     {      
    19.         //dataPath = Application.dataPath + "/GameData/" + System.Environment.UserName + "/" + SceneManager.GetActiveScene().name + ".es3";
    20.  
    21.         autoSaveMgr = GameObject.Find("Easy Save 3 Manager").GetComponent<ES3AutoSaveMgr>();      
    22.         //autoSaveMgr.settings.location = ES3.Location.File;
    23.         //autoSaveMgr.settings.directory = ES3.Directory.DataPath;
    24.         //autoSaveMgr.settings.path = dataPath;
    25.    
    26.         Load();
    27.     }
    28.  
    29.     public void OnApplicationQuit()
    30.     {
    31.        //Save();
    32.     }
    33.  
    34.     public void Save()
    35.     {
    36.         ES3.Save<GameObject>("myGameObject", savedObj);
    37.         //ES3.Save<Vector3>("SampleObjectPosition", savedObj.transform.position, dataPath);
    38.  
    39.         ES3.Save<int>("creatures", creatures);
    40.         ES3.Save<int>("objects", objects);
    41.         ES3.Save<bool>("desktop", desktop);
    42.  
    43.         autoSaveMgr.Save();
    44.     }
    45.  
    46.     public void Load()
    47.     {
    48.         ES3.LoadInto<GameObject>("myGameObject", savedObj);
    49.         //savedObj.transform.position = ES3.Load<Vector3>("SampleObjectPosition", dataPath, savedObj.transform.position);
    50.  
    51.         creatures = ES3.Load<int>("creatures", 0);
    52.         objects = ES3.Load<int>("objects", 0);
    53.         desktop = ES3.Load<bool>("desktop", false);
    54.  
    55.         autoSaveMgr.Load();
    56.     }
    57. }
    58.  
    (I can't edit my previous post anymore)
     
  24. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    530
    It can happen for a number of reasons, so it's not possible for me to tell how to resolve this for your project. Would you be able to private message me a link to a basic project and instructions to replicate it?

    Also just to check, are you loading your prefab instances in the same scene that you saved them?

    All the best,
    Joel
     
  25. joeltebbett

    joeltebbett

    Joined:
    Oct 18, 2009
    Posts:
    530
    Also a quick note regarding your code, you should use ES3.Load rather than ES3.LoadInto to load your GameObject list.

    All the best,
    Joel
     
  26. Beauque

    Beauque

    Joined:
    Mar 7, 2017
    Posts:
    21
    I am preparing you this.

    Yes same scene.

    Noted. I tried both to see if there is a difference.
     
unityunity