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,

    Trying to read all the data from excel, how can I tell how many cells actually have info in it? If I do a loop eventually I run into this:

    [Exception] IndexOutOfRangeException: Cell (0, 6372) is out of bounds of spreadsheet (15, 6372).
    .GetCell() at /Plugins/Easy Save 3/Scripts/ES3Spreadsheet.cs:103
    101: }
    102: }
    -->103: }
    105: public void Load(string filePath)

    .GetCell[T]() at /Plugins/Easy Save 3/Scripts/ES3Spreadsheet.cs:70
    68: public T GetCell<T>(int col, int row)
    69: {
    -->70: var val = GetCell(typeof(T), col, row);
    72: if (val == null)


    Thank you
     
  2. JoelAtMoodkie

    JoelAtMoodkie

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

    If you're unsure of the bounds of the spreadsheet you should catch the IndexOutOfRangeException in a try/catch block.

    All the best,
    Joel
     
  3. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thank you,

    Just in case someone else needs this, this is what worked for me in a loop:


    try
    {
    string temp = tempSheet.GetCell<string>(0, i);

    }
    catch // once it is out of bounds " IndexOutOfRangeException " break it
    {
    Debug.Log("Spreadsheet Total readable cells " + i);
    break;
    }
     
    JoelAtMoodkie likes this.
  4. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Using autosave. For some reason, when I save/load in the continuous gameplay, everything is fine. But if I save, then exit play mode, then start it again and try to load from the file I saved before, some objects lose their materials upload_2021-3-28_23-38-40.png

    Why can it be so?

    EDIT: some investigations showed me that the materials are lost if they are (instance) materials. I'm not sure why they're affected by loading though because I have ES3AutoSave component only on the root object (parent of parents) of the objects where materials are, and it's not saving children, so they probably shouldn't be affected at all?
     
    Last edited: Mar 28, 2021
  5. JoelAtMoodkie

    JoelAtMoodkie

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

    Are you getting any warnings about references not being found in the console? This usually happens when an instance to the Material can't be found (usually because Unity has created an instance of it). This most commonly happens when you use access the 'material' field of a renderer (Unity creates a new instance whenever you access this property).

    All the best,
    Joel
     
  6. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    I Indeed change the "material' field of renderer in these objects. What do I do if I still want to use that field but still save/load correctly?
     
  7. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    @JoelAtMoodkie Hello,

    I have a weird issue where there are 2 empty lines added onto a spreadsheet without any code for it.

    My code currently reads a spreadsheet stores it into a string list, then adds it onto a es spreadsheet (or creates new one if blank)

    int start = total_Excel_Trades;
    for(int k =0; k < tempTime.Count; k++)
    {
    Debug.Log("Line: " +k + " start: " + start);

    excel_Trades.SetCell<string>(1,start, tempDate[k]);
    excel_Trades.SetCell<string>(2,start, tempTime[k]);
    excel_Trades.SetCell<string>(3,start, tempType[k]);
    excel_Trades.SetCell<string>(4,start, tempRef[k]);
    excel_Trades.SetCell<string>(5,start, tempDesc[k]);
    excel_Trades.SetCell<string>(6,start, tempMiscFees[k]);
    excel_Trades.SetCell<string>(7,start, tempCommissFees[k]);
    excel_Trades.SetCell<string>(8,start, tempAmount[k]);
    excel_Trades.SetCell<string>(9,start, tempBalance[k]);

    addEntries++;
    start++;
    tradeNum++;
    }

    So all the debugs go in order 0 to whatever number, however in excel there is 2 blank lines, the 1st one is after 16 entries the 2nd one after 15.. not sure what that means.

    Is this a bug? Can you help me resolve it please,

    Thank you
     
  8. JoelAtMoodkie

    JoelAtMoodkie

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

    Are you making changes to the Material itself, or are you just using the material field to assign a different material? If the latter, you can simply use the 'sharedMaterial' field, as Unity doesn't make a copy when accessing this field.

    All the best,
    Joel
     
  9. JoelAtMoodkie

    JoelAtMoodkie

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

    Please could you create a new script which I can drop into a new project which replicates this? Unfortunately I'm not able to replicate it from what you've posted.

    All the best,
    Joel
     
  10. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hey. I'm changing the material properties. Not assigning other material to it.
     
  11. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    914
    In that case you would also need to save the Material itself (assuming it's serialisable) and load this before loading the object with the renderer which references it.

    All the best,
    Joel
     
  12. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    I also have a problem where for some reason after restarting the game and loading there are many objects created in the scene which I don't want to be created. Some of them have ES3AutoSave component, but they weren't really destroyed in the gameplay, so I'm not sure why it creates them again as new objects?
     
  13. JoelAtMoodkie

    JoelAtMoodkie

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

    Please could you create a new, basic project with a simple scene which replicates this and private message it to me with instructions?

    All the best,
    Joel
     
  14. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Really weird.. in a new project, this issue is not happening. I'll keep you posted if I run into it again.
     
  15. kkiruk

    kkiruk

    Joined:
    Sep 7, 2015
    Posts:
    8
    Hello Joel,

    I'm trying to use easy save3 and anti-cheat toolkit. I wanted to save and load "Obsucured Type" variable from anti-cheat toolkit. So I added the "ObscuredInt" at easy save3 settings - types manually. But when I save and load the variable, it just returns 0. I have no clue what is wrong with this. Please help me. Thanks.
     
  16. JoelAtMoodkie

    JoelAtMoodkie

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

    Unfortunately I don't have experience with Anti-Cheat Toolkit so can only provide limited assistance. Please could you try to replicate this in a new project with a simple scene, and private message this to me with instructions?

    All the best,
    Joel
     
  17. SpaharGR

    SpaharGR

    Joined:
    Dec 5, 2012
    Posts:
    11
    Hello Joel.

    Firstly, I would have to agree with VastnessVR in previous page that your asset would vastly benefit from a more in depth tutorial (either in article form or video).

    I have a question about references, lets say I have two prefab Citizen and House. And Citizen has a reference field "House ownHouse" and House has a list "List<Citizen> inhabitants".

    So, I spawn a citizen and a house, and then I assign the citizen as inhabitant to the house (so that citizen knows its house, but also the house has a list of its inhabitants). I save the two gameObjects (everything works fine here, I see the json in the save file with correct references etc). When I load them:

    Code (CSharp):
    1. ES3.Load("citizen");
    2. ES3.Load("house");
    I get a missing reference warning. Because I load first the citizen it cannot find the House, the house gets the references to the the citizen correctly because it has already been loaded. I understand why this happen. Is there any workaround to this build in ES? For example in a custom solution I tried to build (without ES) I loaded (instantiated) all saved gameObjects and then I updated their references.

    Thanks for your time.

    [Edit] I also tried the Auto Save feature and the same problem occurred. Whichever object loaded first couldn't get the reference to the other.
     
  18. JoelAtMoodkie

    JoelAtMoodkie

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

    The easiest solution would be to save your 'ownHouse' or 'inhabitants' fields separately and load these after you've loaded your other data. E.g.:

    Code (CSharp):
    1. var citizen = ES3.Load("citizen");
    2. var house = ES3.Load("house");
    3. citizen.ownHouse = ES3.Load("ownHouse");
    Or if you don't want to save it seperately, you could simply load the Citizen twice:

    Code (CSharp):
    1. ES3.Load("citizen");
    2. var house = ES3.Load("house");
    3. ES3.Load("citizen"); // Load again now that all references exist.
    All the best,
    Joel
     
  19. SpaharGR

    SpaharGR

    Joined:
    Dec 5, 2012
    Posts:
    11
    Thx for the quick response.

    Can you shed also some light about the references of a prefab. I have set up two prefabs with pretty simple structure:

    Code (CSharp):
    1. Citizen (with Citizen Component and ESPrefab Script)
    2. -- Visual (3D Model)
    As you can see I have two prefabs and 435 references:
    es1.JPG

    The majority of the references are from the 3D models of the prefabs:
    es2.JPG

    Isn't this an overkill? Does it have a performance impact and if yes are there any workarounds?

    Thank again.
     
    Last edited: Apr 23, 2021
  20. JoelAtMoodkie

    JoelAtMoodkie

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

    The reference manager will store anything which is referenced by your scene (this doesn't mean that all of these references are saved). As this is just a Dictionary of references, it won't have an impact on performance.

    For more information please see the Saving and Loading References guide:
    https://docs.moodkie.com/easy-save-3/es3-guides/saving-and-loading-references/

    All the best,
    Joel
     
  21. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Hello,

    Looking at the example on the documentation:

    ES3.Save("myList", myList);
    myList = ES3.Load("myList", defaultValue);

    What would defaultValue be?

    can I do this:
    myList = ES3.Load("myList", myList);

    Thank you
     
  22. JoelAtMoodkie

    JoelAtMoodkie

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

    The defaultValue is what is returned if there is no save data to load. For more information please see the Getting Started guide:

    http://docs.moodkie.com/easy-save-3/getting-started/

    All the best,
    Joel
     
  23. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Hi there - anyone having issues with Visual Studio (Mac) and intellisense? EasySave never had issues before, but now in VS I get Type/Namespace not found for everything ES3 related (eg [ES3NonSerializable] ) I don't get any errors in Unity though.....but it's annoying to see it in VS and can't get intellisense to work in VS with ES3.

    Here are current settings:



    Thanks
     
    Last edited: Apr 26, 2021
  24. JoelAtMoodkie

    JoelAtMoodkie

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

    Intellisense is controlled by Unity and Visual Studio, so I can only provide limited assistance. However, when similar things have happened to me with other assets in the past, rebuilding the project resolved the issue. I did this by making a backup of my project, and then removing the Library and Temp folders from my project to force Unity to rebuild them.

    All the best,
    Joel
     
    SaltwaterAssembly likes this.
  25. SaltwaterAssembly

    SaltwaterAssembly

    Joined:
    Mar 8, 2016
    Posts:
    95
    Thanks will try this again.
     
  26. EmpireStudios

    EmpireStudios

    Joined:
    Oct 23, 2018
    Posts:
    24
    For Playmaker the Save All and Load All actions don't seem to work.
    Settings : FSM : State 1 : LoadAll : System.IO.FileNotFoundException

    There is no default value for Load All.
     
    Last edited: Apr 26, 2021
  27. JoelAtMoodkie

    JoelAtMoodkie

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

    This error should only occur if no save data exists (i.e. no data has been saved to a file with that name before). Please could you replicate this in a new project and private message it to me.

    All the best,
    Joel
     
  28. EmpireStudios

    EmpireStudios

    Joined:
    Oct 23, 2018
    Posts:
    24
    Sure I'll do that, note this is only happing for Load All. If I use just the Load action I see that the file gets auto created if there isn't one already.
     
  29. JoelAtMoodkie

    JoelAtMoodkie

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

    None of the load actions or methods should automatically create files (we've certainly not designed them to do so at our end). Are you sure this is happening?

    All the best,
    Joel
     
  30. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Does Load Audio action work correctly for anybody here?
     
  31. JoelAtMoodkie

    JoelAtMoodkie

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

    We don't appear to be having any issues at our end. Please could you describe the issues you're encountering?

    All the best,
    Joel
     
    Crossway likes this.
  32. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    Hi, I get errors like this

    FSM : State 1 : LoadAudio : System.InvalidOperationException: Cannot access the .audioClip of an aborted DownloadHandlerAudioClip at (wrapper managed-to-native)
     
  33. JoelAtMoodkie

    JoelAtMoodkie

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

    I've had no reports of this before. Please could you replicate this in a new project with a simple scene and private message it to me?

    All the best,
    Joel
     
  34. melksnis

    melksnis

    Joined:
    Sep 30, 2020
    Posts:
    10
    Hello!
    I have a complex object I want to save - a car with about 200 parts. I tried using prefab- the problem is if I have removed door (deleted) It still loads that door from prefab.- maybe there is a way to not load a part of prefab if it is deleted? (I know I can delete it after loading but maybe there is a function in this asset I have missed?)
    I tried to use autosaving the whole gameobject but again I ran in issue - some meshes don't load - some have correct mesh name but shows 0 vertices other just show mesh missing - maybe I have to reference the mesh from resources somehow.. . And when I try to save other car (saving all gamoebject) I have error like texture 2d not supported - just can't find the object in hierarchy causing this
    Maybe there is something in all above I can fix easily?

    Basicly if I could just have my prefab not load deleted parts all would be good
     
    Last edited: May 3, 2021
  35. JoelAtMoodkie

    JoelAtMoodkie

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

    The serialization tree is unable to determine what has been destroyed because it wouldn't be possible for it to tell that the GameObject ever existed on saving, nor tell the difference between something which has been destroyed, something which has been moved or something which has been added to the GameObject at runtime upon loading.

    In these cases it is usually better to toggle the active state of the GameObject rather than destroying it.

    All the best,
    Joel
     
  36. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hello Joel,

    I'm also getting this error mentioned before.
    Easy Save: Version 3.3.2f1 - January 25, 2021
    Unity: 2020.3.5f1

    NullReferenceException: Object reference not set to an instance of an object
    UnityEngine.Rendering.VolumeComponent.GetHashCode () (at Library/PackageCache/com.unity.render-pipelines.core@10.4.0/Runtime/Volume/VolumeComponent.cs:215)
    UnityEngine.Rendering.VolumeProfile.GetHashCode () (at Library/PackageCache/com.unity.render-pipelines.core@10.4.0/Runtime/Volume/VolumeProfile.cs:299)
    System.Collections.Generic.ObjectEqualityComparer`1[T].GetHashCode (T obj) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.Collections.Generic.Dictionary`2[TKey,TValue].set_Item (TKey key, TValue value) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    ES3Internal.ES3ReferenceMgrBase.Add (UnityEngine.Object obj, System.Int64 id) (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:253)
    ES3Internal.ES3ReferenceMgrBase.Merge (ES3Internal.ES3ReferenceMgrBase otherMgr) (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:127)
    ES3Internal.ES3ReferenceMgrBase.Awake () (at Assets/Plugins/Easy Save 3/Scripts/ES3ReferenceMgrBase.cs:105)
     
  37. JoelAtMoodkie

    JoelAtMoodkie

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

    Updating to the latest version should resolve your issue.

    All the best,
    Joel
     
  38. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Sorry I tried to update before I wrote it and though I am up-to-date.
    But for some reason package manager is unable to update Easy Save now (other assets seem to work fine). Will try it later. Thanks for info.
     
  39. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Hello,

    for the es3 files, how big a file is too big that it starts slowing things down, or how many lines?

    Just trying to figure out how to structure the save data(s).

    Thank you
     
  40. JoelAtMoodkie

    JoelAtMoodkie

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

    This wouldn't be possible for me to say as this depends on your app and the device it's running on. Generally however if you're using caching then file size shouldn't slow things down as it's loading from RAM rather than storage.

    All the best,
    Joel
     
  41. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thank you,

    How can I make the "settings" a variable across my class? I'd like not to have to state what var settings is for each void...

    I don't think this worked: public ES3Settings settings = new ES3Settings(ES3.Location.Cache);

    Is there a way to tell it the default settings / path will be under a cache (filename) instead? similarly to ES3Settings.defaultSettings.path = "filepath.es3";
     
  42. JoelAtMoodkie

    JoelAtMoodkie

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

    You can change the default location to Cache in Tools > Easy Save 3 > Settings.

    All the best,
    Joel
     
  43. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    I found that and changed it, I seem to be running into some issues though. During runtime at one point I do this ->

    var settings = new ES3Settings(ES3.Location.File);

    Load a bunch of stuff via: ES3.Load("individual_Sites", KZDevelopment_DB_SavePath, individual_Sites, settings);

    Then later on when I try saving things normally by: ES3.Save((stringTitle), "string here");
    Seems to work fine (it saves into cache),

    However when I get into ->
    ES3.KeyExists(stringTitle)
    and ES3.Load("Name").ToString();

    It doesn't load them up, I am assuming because I then need to tell it this? ES3.CacheFile("Cache.es3");
    Why does that have to be done, is it because i temporarily loaded some info from the var settings and ES3 now thinks its via the file instead?

    My next question then is

    Why does this work
    - string tempStr = ES3.Load(keyStr).ToString();

    But this does not:
    - string tempStr = ES3.Load(keyStr, tempStr);

    Lastly,
    It seems if it is a array[] that is saved within ES3 I must specify a path otherwise it does not work, is this correct? Example:

    bool[] binsDone = new bool[4];
    binsDone = ES3.Load("binsDone", "filepathneeded?", binsDone);

    How can I load it up without having to specify the file path, if its mandatory then I need to do this? var settings = new ES3Settings(ES3.Location.Cache);
    and for "filepathneeded" put settings?


    I hope this makes sense and thank you for helping me clarify this so I can continue taking the right approach
     
    Last edited: May 9, 2021
  44. JoelAtMoodkie

    JoelAtMoodkie

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

    There seems to be quite a few errors in your code.

    Regarding your first issue, you don't appear to be providing your settings object when calling the other ES3 methods, and don't seem to be providing the save path you provide when loading. Also I can't see anywhere in your code where you're storing the cached data to file. For more information please see the caching guide: https://docs.moodkie.com/easy-save-3/es3-guides/performance/

    Also this code you seem to be looking for the existence of a key, but then loading a different key:


    Code (CSharp):
    1. ES3.KeyExists(stringTitle)
    2. and ES3.Load("Name", KZ_Data).ToString();
    Regarding your second question, the second parameter to the load method in this situation would be the filePath. If you want to use the default parameter with strings you should use the ES3.LoadString method.

    Regarding this code:

    Code (CSharp):
    1. binsDone = ES3.Load("binsDone", "filepathneeded?", binsDone);
    You can simply remove the filePath parameter if you don't want to provide a file path.

    Code (CSharp):
    1. binsDone = ES3.Load("binsDone", binsDone);
    All the best,
    Joel
     
  45. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thank you for your help,

    When I try to remove the filePath I get an error, for example:

    string title = "";
    title = ES3.Load("Title", title);

    Cannot implicitly convert type 'object' to 'string'. An explicit conversion exists (are you missing a cast?)
     
  46. JoelAtMoodkie

    JoelAtMoodkie

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

    I think you may have missed my response to your question previously:

    All the best,
    Joel
     
  47. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Thank you so much,

    I figured it out with your help. It all works as it should, I was just confused because of the string ones I should use LoadString and the rest works as intended.

    As per my previous question on what size is too much a size, roughly every week about 200 lines will be added to the save file, thats over 10,000 lines for the year. Should I look for ways to re-structure the file maybe by quarterly or yearly to ensure its performance, or as you've previously stated the size shoulnd't slow it down due to caching?

    Thanks again for your swift support even on a weekend.
     
  48. zKici

    zKici

    Joined:
    Feb 12, 2014
    Posts:
    438
    Sorry a couple more questions..

    I moved my file to Resources - KZDevelopment.es3
    Reason for that is it will be required during runtime in mobile build,
    Changed my code from
    -> var settings = new ES3Settings(ES3.Location.File);
    to ->
    var settings = new ES3Settings();
    settings.location = ES3.Location.Resources;


    ArgumentException: Extension of file in Resources must be .json, .bytes, .txt, .csv, .htm, .html, .xml, .yaml or .fnt, but path given was "KZDevelopment.es3"

    How do I convert my es3 to these files that are needed instead?


    What is the best practice to turn string into int, this is what I am currently doing:
    int tempInt = 0;
    int.TryParse((ES3.Load((stringWithNumber))).ToString(), out tempInt);
     
    Last edited: May 10, 2021
  49. JoelAtMoodkie

    JoelAtMoodkie

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

    This depends on the hardware you're running on. However, let's assume that the average line is 100 bytes in length, that means 10,000 lines is only 1 megabyte. So unless your lines are particularly long, I wouldn't see that amount of data as being an issue.

    All the best,
    Joel
     
    Last edited: May 10, 2021
  50. JoelAtMoodkie

    JoelAtMoodkie

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

    You need to change the extension to .bytes. Please see the documentation:
    https://docs.moodkie.com/easy-save-3/es3-guides/saving-loading-resources/

    Regarding changing a string into an int, I'm afraid I can only provide support for things relating directly to Easy Save. However, Microsoft has a guide on this: https://docs.microsoft.com/en-us/do...ide/types/how-to-convert-a-string-to-a-number

    All the best,
    Joel