Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Easy Save - The Complete Save Data & Serialization Asset

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

  1. romaxl30

    romaxl30

    Joined:
    Aug 16, 2020
    Posts:
    5
    Oh, thank you for paying attention. I have already found a solution to my "stupid" question - using Playmaker ArrayMaker - when saving, I add all the objects I want to an array of objects, I take the values I need from them and also add them to arrays that correspond to their type. And when loaded, based on the indexes of the saved objects, I load their saved values. It might be a little confusing, but it seems to work well. Here is a screenshot - maybe it will help someone)

    Thanks again Joel for your attention save.png
     
    JoelAtMoodkie likes this.
  2. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hello. I have a big scene with a lot of objects + additive scenes and doing Easy Save using both Auto Save and manual saving.

    When I have Easy Save 3 Manager added to the scene, my loading time of the scene in the editor becomes insane. It changes from 1-2 minutes without this object to 15-20 minutes with this object.

    That makes it very difficult to work/test the saving system. Is there ways to fix it?
     
  3. JoelAtMoodkie

    JoelAtMoodkie

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

    We’ve not seen this before, but all the Easy Save 3 Manager does is contain a list of all of the references in your scene and a unique ID for each, so I’m surprised this is affecting performance.

    Assuming Unity is struggling with the quantity of references, the alternative is to only add the references to the manager which need storing. You can do this by going to Tools > Easy Save 3 > Settings, unchecking Auto Add References and then deleting the Easy Save 3 Manager from your scene, and then re-adding it (Tools > Easy Save 3 > Add Manager to Scene). You will also need to delete any existing save data (Tools > Easy Save 3 > Clear PersistentDataPath), and manually add anything which needs to be saved by reference by right-clicking it and selecting Easy Save 3 > Add References to Manager.

    All the best,
    Joel
     
  4. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hey. Thank you. Do I need to add only the components that have ES3AutoSave(The ones that are auto saved)?
     
  5. JoelAtMoodkie

    JoelAtMoodkie

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

    You need to add anything which is saved by reference. Usually if you're saving GameObjects, right-clicking the GameObject and selecting Easy Save 3 > Add References to Manager will be enough. However, for example if you were to change a field of the GameObject from one reference to another at runtime, you would also need to ensure that reference is added to the manager. It's usually obvious when a reference hasn't been added to the manager as you'll get a warning in console when loading.

    All the best,
    Joel
     
  6. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hello.

    I figured out that if I delete easy save manager and add a new one, and add references automatically to this new one, it works fast. Maybe my manager is full of unused references? But if I add new one, I have other errors with saving that appear. Can I press "Optimize" on my manager, should it help in this case?
     
  7. JoelAtMoodkie

    JoelAtMoodkie

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

    The Optimize button will remove any references which aren't referenced by your scene, so it may help in this case.

    All the best,
    Joel
     
  8. Milanese

    Milanese

    Joined:
    Jul 6, 2015
    Posts:
    4
    Hello,

    I'm trying to add a password encryption to my save files but I can't make it happen for some reason. I tried scripting it and tried with the runtime settings under the easy save window in unity. I read the documentation already and implemented what it says there.

    How does the password work exactly? What we want is some way to prevent players from tampering with the save files. Is this the best way to do this?
     
  9. JoelAtMoodkie

    JoelAtMoodkie

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

    Please could you show me the code you are using? You should just need to set the encryption mode to AES (either using an ES3Settings object or from the Settings window), as described in the Encryption guide:

    https://docs.moodkie.com/easy-save-3/es3-guides/es3-encryption-compression/

    All the best,
    Joel
     
  10. Milanese

    Milanese

    Joined:
    Jul 6, 2015
    Posts:
    4
    Hello, This is the code I'm using for one file, but I would rather set it in the default settings so I don't have to code it for the rest of the files I save.

    upload_2022-8-18_11-38-20.png

    How does the password work? If setting a password, does that mean that when opening the file on a notepad or similar program, a box will appear asking for a password? I don't fully understand the extend of this feature, if you could elaborate on this a bit more I would greatly appreciate it
     

    Attached Files:

  11. JoelAtMoodkie

    JoelAtMoodkie

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

    Your code appears to be working at my end. If you replicate this in a new project with a simple scene (either using ES3Settings or using the settings window) and private message it to me I’m happy to take a further look.

    The file will just look like a random set of characters when opened in a text editor. As far as we’re aware no text editors will display a password prompt when opening an encrypted file (this would be something the text editor would need to implement rather than something at our end).

    All the best,
    Joel
     
  12. Milanese

    Milanese

    Joined:
    Jul 6, 2015
    Posts:
    4
    Hi,

    Thank you for the info. What is the password function then? The documentation doesn't explain how to use it. I would like to have a way to be able to read a file but make it impossible for the user to read it. I thought there was a way to set a password in the ES3 asset in unity to be able to see the contents clearly, but the player would see them as a string of random characters.

    Can I do something like this with ES3?
     
  13. JoelAtMoodkie

    JoelAtMoodkie

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

    Encryption is documented in the encryption guide:
    https://docs.moodkie.com/easy-save-3/es3-guides/es3-encryption-compression/

    Once data is encrypted it is not intended to be read via a text editor. Instead you should access the file using ES3 methods, which will decrypt the data before reading it.

    All the best,
    Joel
     
  14. Inth

    Inth

    Joined:
    Jan 29, 2013
    Posts:
    3
    Hi I use Bolt
    I have added a variable to an object in Inspector
    object has ES 3 script on it in setting variables are checked

    I use Auto save
    I run the game
    change the variable
    close the game
    when I load the game in Editor the variable remains as it was at the very beginning

    any Idea what am I doing wrong ?
     

    Attached Files:

    • es3.png
      es3.png
      File size:
      11.8 KB
      Views:
      131
  15. JoelAtMoodkie

    JoelAtMoodkie

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

    The required fields of the Variable script aren't serializable at runtime. Instead you should use the Save and Load units from within Bolt to save and load your variables.

    All the best,
    Joel
     
  16. gooby429

    gooby429

    Joined:
    Aug 13, 2019
    Posts:
    128
    Hello, would just like to report that importing the package after the latest update removed all my defines and replaces them with the visual scripting defines even if we dont use visual scripting.
     
  17. JoelAtMoodkie

    JoelAtMoodkie

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

    Please could you replicate this in a new project and private message it to me with instructions, along with the version of Unity you are using? We've had no other reports of this and it appears to be working fine in our testing, so this indicates a bug at Unity's end.

    All the best,
    Joel
     
    gooby429 likes this.
  18. K97

    K97

    Joined:
    Mar 24, 2016
    Posts:
    10
    Hi Joel,

    I have a monobehaviour script which mainly has primitives, but also Textures. Since textures are not supported, saving this file is throwing NotSupportedException. Is there a way I can ignore saving textures and not getting exceptions? (since in my case it's not mandatory to save those textures)

    I am afraid that some data may not be saved when above exception is thrown.
     
  19. JoelAtMoodkie

    JoelAtMoodkie

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

    This happens when you have a field of type Texture, and the texture type isn't a Texture2D. In this case you can give the field the [ES3NonSerializable] attribute. For more information please see the Choosing what is Saved guide:

    https://docs.moodkie.com/easy-save-3/es3-guides/choosing-what-is-saved/

    Alternatively you can set the field type to the specific Texture you're saving (rather than 'Texture'), and Easy Save will ignore it.

    All the best,
    Joel
     
  20. krakentanz

    krakentanz

    Joined:
    Aug 13, 2020
    Posts:
    34
    Hey Joel, sorry for the long read:

    We're using EasySave3 to save some specific GameState-Data locally (and then syncing it with a ES3Cloud). I say specific data because we already have code in place to keep track of what needs to be saved/loaded, and who references whom - so EasySave doesn't have to do this for us.
    We would, however, love to use ES3s feature to conveniently create a custom Type and then just give ES3 some GameObject to serialize, save. load etc. These objects can and should always be saved by value (as i said - we took care of dependencies and duplicate stuff), so i thought i can just set Settings > Advanced > "Serialise Unity Object fiels" to "By Value" and get rid of the need for the EasySave Manager counting Refs alltogether. (To keep the footprint of the project small and not have someone keep references to Objects that we never need, potentially messing with GarbageCollection etc.)

    Unfortunately, if i set "Serialise Unity Object fields" to "By Value" i will still get this exception:

    InvalidOperationException: An Easy Save 3 Manager is required to load references....


    When i step through the code i find the culprit being in ES3UnityObjectType.cs line 36


    if(mode != ES3.ReferenceMode.ByValue)
    {
    if(refMgr == null)
    throw new InvalidOperationException("An Easy Save 3 Manager is required to load references...");
    ...

    In the debugger i can see that that mode variable there has the value "ByRefAndValue" at the time this code runs, which is not what i have set in the Settings from the unity Inspector. Would it be "ByValue" as i want it to be, i would not have any issues as it would just jump to line 44 and call
    WriteUnityObject(instance, writer);

    omitting the call to the refMgr Manager.

    Here's my question: What am i missing? Am i working against everything that is EasySave when i try to not use the Manager? Can it be done? Is it a bug that 'mode' is magically set to "ByRefAndValue", or does it get reset for a good reason somewhere else?

    Hope i managed to put this as a somewhat clear question - curious what you think of this!!
     
    Last edited: Aug 30, 2022
    burakkurkcu likes this.
  21. JoelAtMoodkie

    JoelAtMoodkie

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

    This happens because we’re reliant on referencing to correctly serialise a GameObject, as this is the only way we can uniquely identify each Component on it (order isn’t guaranteed in Unity).

    It also doesn’t make sense to serialise some things by value when serialising a complete GameObject. For example, a Transform’s parent serialised by value would mean that we need to create a new GameObject with a new Transform each time we load in order to deserialise this data.

    Regarding reducing your footprint, the reference manager is just a list of references which already exist in your scene, so the impact is extremely low. If you want to minimise this list you can disable Auto add references to Manager in the settings and only add the references to the manager you need by right-clicking them and selecting Easy Save 3 > Add references to Manager.

    All the best,
    Joel
     
    andreiagmu and krakentanz like this.
  22. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hello.

    I had a problem with a very big scene loading time with Easy Save 3 Manager.(Posted here before about that problem). My scene loading times without the manager was 30 seconds and with it 10 minutes.

    We made a hypothesis it was because of the number of references in the manager. We tried to press "Optimize" button on the manager, and the result was that Unity freezed with loading for 5 hours, after that the optimization didn't happen though and loading times were the same.

    I tried to completely remove the easy save manager and add a new one. Now it loads fast, however the ES3AutoSave objects don't really work like they were before. When I load the game, the positions and the active/inactive state of the objects do not load anymore. And the console doesn't show any exception after loading, I debugged and the script successfully passed throuh ES3AutoSaveMgr.Load() function. But it's not working properly.

    I tried to remove all the ES3AutoSave components on the scene except only on one object(just to test if it works at all). Nope, doesn't load the position.

    What can be the reason?
     
    Last edited: Sep 6, 2022
  23. JoelAtMoodkie

    JoelAtMoodkie

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

    Did you delete your previous save data after deleting the Easy Save Manager? Deleting the manager will also delete the reference IDs and generate new ones, so your previous save data will no longer be valid.

    All the best,
    Joel
     
  24. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    What do you mean by save data? Save files? Yes, I'm saving on new save files and try to load new ones, not the old ones.
     
  25. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    I just tried to clean persistent data path and result is the same. It doesn't load anything. Even when I have only one object with ES3AutoSave
     
  26. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hmmm I think I just noticed what the problem is. In the Auto Save settings, some components like "Transform" are unchecked(so they are not saved) even though they were checked before. The weird thing is that even when I check them and start the game, they still don't load, and when I exit playmode they are again unchecked in that menu(even though I did check them before entering playmode).

    Do you know why some of the components could be unchecking after entering playmode in that menu?
     
    Last edited: Sep 6, 2022
    andreiagmu likes this.
  27. JoelAtMoodkie

    JoelAtMoodkie

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

    We've had reports of something similar but haven't been able to replicate it at our end yet. Are you using any assets which might affect how the Editor works?

    Also would you be able to let us know what version of Unity you are using? We've not changed the way that the Auto Save Editor works for quite some time but reports of this have only been recent, so we suspect it could be a bug with a particular version of Unity, or a conflict with an update from another asset.

    All the best,
    Joel
     
    Last edited: Sep 7, 2022
  28. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174

    No, I'm not using anything influencing editor.

    Unity 2020.1.5f1
     
  29. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    912
    Is this happening with scene objects, prefabs or both?

    All the best,
    Joel
     
  30. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    scene objects. I didn't try prefabs. Although this object IS a prefab, but I'm not saving it as a prefab in Easy Save
     
  31. JoelAtMoodkie

    JoelAtMoodkie

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

    We think we've managed to track this down to an bug at Unity's end. Though we've still not been able to replicate it at our end, we have an update which appears to have resolved the issue for another user. If you private message me your invoice number I'll send the update over so you can see if it resolves your issue.

    All the best,
    Joel
     
    andreiagmu likes this.
  32. SnaiperoG

    SnaiperoG

    Joined:
    Apr 6, 2015
    Posts:
    66
    Hello. I have few problem with es3. Im using it on my server to save players information. Ive used it like ES3.Save and ES3Load, but when there are many players to save I have a huge fps drops. So ive did it in another way. I started to use Task like that: https://pastebin.com/XrQyVPUS (this is how im using it now) and found in docs (to be honest docs are bad to understand and it need more examples how to use it) info about Writers and Readers. (already changed to es3file, ill describe about it next). But with this logic i have bugs with saving, for some reason i can see in the directory 2 files: *.es3 and *.es3.tmp. Both have corrupted data. First one had NULLNULLNULL at 1 row. Second one had problems with " and {. Next, I found info about ES3File. (pastebin will show how it looks now). But I have another problem. I found that i have corrupted file again, but now corruption was at Vector3 saving. I didnt saved that but corruption was with z value of vector3 data. It looks like that (z value was as a string):
    {
    "x":100,
    "y":100.
    "string":"z":{
    }:"100"
    }
    Also idk when it happening, I guess when there are 2+ saves in the row, because im doing save now everytime player disconnecting from server. But now i dont have any ideas, i have 2 servers for now and first one was good tonight, but 2 one had a corrupted file (with z value)
     
    Last edited: Sep 11, 2022
  33. Stickeyd

    Stickeyd

    Joined:
    Mar 26, 2017
    Posts:
    174
    Hello. I think the fix you sent me fixed the issue with UI, but there is one more problem(or request).

    It seems that how the auto saving works changed at some point... I'm not sure why and when. But before that, how it worked for me is that I never used UI for Auto Save, I just added ES3AutoSave component to objects and Easy Save automatically saved any components that I have types scripts created for. I even checked my previous commits at Git and I noticed that I don't have anything checked at all in AutoSave UI actually. But the objects and components save and load properly because they have ES3AutoSave. So back then if I needed to include any new component I was just creating a new ES3UserType(via types UI) and added the component ES3AutoSave to the object. There were no need to check anything in the Editor Auto Save UI for me. However it doesn't work like that anymore and combined with my previous problem of having to recreate Easy Saving Manager, it means that I have to manually check ALL the components that I had types for before in that UI. Otherwise they won't save. And this takes a very long time for me since I have hundreds of objects.

    Is there any way for a quick solution of this for me?
     
    Last edited: Sep 11, 2022
  34. JoelAtMoodkie

    JoelAtMoodkie

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

    Documentation for ES3Reader/Writer/ES3File is only included in the API reference for legacy purposes, which is why there is no guide for it.

    Instead you should use caching, which achieves the same thing but with a less error prone API, which is documented in the Improving Performance guide:

    https://docs.moodkie.com/easy-save-3/es3-guides/performance/

    I also recommend deleting your existing save data to ensure you’re not saving to a corrupt file.

    Another thing to note: if using asynchronous code you must ensure that only one thread is accessing the file at a time, and that the data you are saving is thread safe. Generally caching is fast enough that you rarely need to run Easy Save in a separate thread.

    All the best,
    Joel
     
    andreiagmu likes this.
  35. JoelAtMoodkie

    JoelAtMoodkie

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

    Auto Save is only intended to be used with the UI, and the use case you speak of has never been intended.

    If you want all supported Components to be saved you should use the API instead and save/load GameObjects or arrays/Lists if GameObjects. This will save all supported Components on those GameObjects.

    All the best,
    Joel
     
  36. SnaiperoG

    SnaiperoG

    Joined:
    Apr 6, 2015
    Posts:
    66
    Thanks for answer. Ive tryied to use ES3Settings and file cache, but with this docs i cant figure out how to use it. When i trying to cache, if file doesnt exist it throw an error, when i create a file by ES3Save, just for creating a file, then cache it. i cant save it from cache to disk, it throw an error, this ES3Setting usage description is very undocumentated, you should put here a full code example, how to load, cache and save it with ES3Setting. Because I have for example few places in the code where i do save and do load a file, and how to use ES3Setting is very complicated for now. What ES3Setting is? When i need to create a new one? Will it destroyed after usage in the memory?

    Also I found a backup feature, how it can be used? Lets say i will backup some file every 5 minutes. Will it be one file or many? How to check did it proper save without corruption or not? I see it now like to use try catch when loading a file and if there is an error, use a backup file
     
  37. JoelAtMoodkie

    JoelAtMoodkie

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

    Please could you show me the code you're using, or replicate this in a new project with a simple scene and private message it to me?

    ES3Settings is just an object which you provide to the Easy Save methods to specify what settings you want to use when calling that method.

    This is documented here: https://docs.moodkie.com/easy-save-3/es3-guides/backups/

    As you'll see in the example, you specify which file you want to back up. It will make a single backup of this file.

    This is the way it's most commonly used. I.e. if you have an exception which you can't recover from, attempt to restore from backup and try reloading. You can find an example of this in the Restoring a Backup section of the Backups guide.

    All the best,
    Joel
     
  38. SnaiperoG

    SnaiperoG

    Joined:
    Apr 6, 2015
    Posts:
    66
    Thanks for help and clarification. Ive got again corrupted save file right now, but my server had a crash before it this time. At this time i have int value corruption. https://pastebin.com/0hBNWjjW
    I hope its because of Tasks and threads (this is my script to work with saves on the server https://pastebin.com/ApXV5wuA), I will try to use another way these days. If it will still appear I will pm to you. Thanks for help
     
    JoelAtMoodkie likes this.
  39. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    73
    Hi, thanks for this great serializer!

    I have a few requests:
    1. Add a setting to specify the folder where ES3 types are created by default. I have them in a separate assembly and dont want to clutter my project root (ES3 is in my plugins folder).
    2. Apparently the Easy Save type search does not find classes marked "internal".
    3. Also show fields marked as non-serialized in the types window (maybe show a hint that they are not meant to be serialized). This is useful for 3rd party code, i.e. if they have serializable dictionaries that are converted to lists - ES3 doesnt invoke the hooks but it doesnt matter because it can directly serialize the dict.
    4. a) Also look for private parameterless constructors. Private constructors is a common pattern for serializer support, so in "normal" code the constructor doesnt get exposed. Right now I have to create ES3 types for these classes which is a bit tedious.
    4. b) Going one step further: Dont require a constructor at all, like the Unity JSONUtility by instantiating objects with FormatterServices.GetUninitializedObject (I assume thats what they do).
    5. I have some cases of serializable classes that are created inside the constructors of their serializable parent. They get the parent injected into the constructor and do not have parameterless constructors. In this case it would be useful to have an option that says: dont create an instance, just set the properties on the field of the parent - its already instantiated. I guess this would require a new category of options for auto reflected types (maybe also for point 4),
    6. Provide a function Read(Type type) in ES3Reader, so we can use reflected types from private or internal classes.
     
    Last edited: Sep 14, 2022
  40. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    912
    Hi there, and thanks for the requests.

    As this is the first time this has been requested I've added a feature request for this here:
    https://moodkie.com/forum/viewtopic.php?f=14&t=2657

    This is by design, as it's not possible to know where in your project to place the ES3Type file for it to be part of the assembly containing the internal class. Instead you would need to manually create the ES3Type file yourself in a place where it would be accessible (though this is probably another reason to include your first feature request).

    This is also by design as there are situations where something might be marked as non-serialized but a user has a reason to serialise it (for example, an inherited class which adjusts the functionality so that it can be serialised). However, I can see that it would be useful to have this indicated so I've created a feature request for this here:
    https://moodkie.com/forum/viewtopic.php?f=14&t=2658

    We've intentionally not implemented this for a couple of reasons. Firstly, in C# a private constructor has special meaning and isn't simply a constructor hidden from other classes. It would also require different logic for different platforms as we currently use Activator.CreateInstance (which has performance benefits over manually calling the constructor) which works across all platforms, but .NET Core does not allow private constructors to be called using this. It would cause fewer issues to simply implement your next request, but I've created a feature request for this here nonetheless :)

    We have actually incorporated this in the past but ran into issues, so instead reverted back to requiring a parameterless constructor. The first issues was that there were numerous bugs around IL2CPP and FormatterServices.GetUninitializedObject, though these have (hopefully) since been resolved. The main issue however was that .NET Core doesn't support it, and although the documentation indicated that it would behave differently, people felt very negatively when they came to port their game to .NET Core and found that they had to rewrite parts of their code. In the end it caused fewer issues for users to simply require a parameterless constructor on all platforms. However, it is near the top of our backlog to revisit this and see if there's a best-of-both-worlds approach which doesn't cause a poor experience for .NET Core users.

    Would you be able to provide a simple example of this so I fully understand what you mean? A script which I can drop into a new scene of a new project would be ideal. Feel free to private message it to me if it's easier.

    Again, would you be able to provide an example of this? I'm not sure I fully understand.

    All the best,
    Joel
     
  41. Falondrian

    Falondrian

    Joined:
    Nov 1, 2017
    Posts:
    73
    Thanks for the quick and in-depth reply! :)

    3. As far as I can see, fields marked as NonSerialized are currently not shown in the Types window at all. My request was to show them.

    5. In the following example the Child does not need to be instantiated by the deserializer because the parent already creates it. It would be fine to set the _someInt field directly on the parent classes _child reference. It would be nice to have an option so this is done automatically.

    Code (CSharp):
    1. [Serializable]public class Child
    2. {
    3.     [SerializeField] int _someint = 0;
    4.     public Child(Parent parent)
    5.     {
    6.         //do stuff with parent
    7.     }
    8. }
    9.  
    10. [Serializable]public class Parent
    11. {
    12.     private Child _child;
    13.     public Parent()
    14.     {
    15.         _child = new Child(this);
    16.     }
    17. }
    6. ES3Reader provides the following function
    Code (CSharp):
    1. public virtual T Read<T>()
    2. {
    3.     return Read<T>(ES3TypeMgr.GetOrCreateES3Type(typeof(T)));
    4. }
    I would like to have a non-generic version. When serializing private or internal classes their Type has to be acquired via reflection so a generic method cannot be used.
    Code (CSharp):
    1. public virtual object Read(Type type)
    2. {
    3.     return Read(ES3TypeMgr.GetOrCreateES3Type(type));
    4. }
    5.  
    6. reader.SetPrivateField("someField", reader.Read(Type.GetType("OtherAssembly.SomeInternalClass")), instance);
    7.  
     
    Last edited: Sep 16, 2022
  42. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    912
    Apologies, I clearly hadn't had my morning coffee at that point as I was getting the behaviour of the Auto Save window (which displays unsupported Components) mixed up with the behaviour of the Types window (which doesn't show unsupported fields as it's not possible to generate an ES3Type for them without compiler errors). However, those marked as NonSerialized aren't limited by these so I'll update the feature request accordingly.

    Thanks for the clarification, I've added a feature request for this which hopefully describes it adequately:
    https://moodkie.com/forum/viewtopic.php?f=14&t=2661

    Thanks, I've created a feature request for this here:
    https://moodkie.com/forum/viewtopic.php?f=14&t=2662

    All the best,
    Joel
     
    Falondrian likes this.
  43. SnaiperoG

    SnaiperoG

    Joined:
    Apr 6, 2015
    Posts:
    66
    Ive tryied to use backup feature, but its impossible to use for big files. I have a game server with file with all saved players info. It can be a big file. And for now i have drop to 700ms when backuping this file. So its impossible to use by regular main thread logic. And i dont have any options with es3 for backup as i guess. I did a change in my logic from tasks to coroutines, i hope it will fix previos problems with saving.
     
  44. JoelAtMoodkie

    JoelAtMoodkie

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

    You should be able to call the backup methods from a separate thread as all it does is create a duplicate of the file. It doesn't perform any serialisation.

    Alternatively you can create your own copy of the file using the System.IO methods. There is discussion on a number of ways this can be performed here:
    https://stackoverflow.com/questions/882686/non-blocking-file-copy-in-c-sharp

    All the best,
    Joel
     
  45. SnaiperoG

    SnaiperoG

    Joined:
    Apr 6, 2015
    Posts:
    66
    Thanks for reply. I guess its an only way to do it. Is it possible as a request feature for es3?
     
  46. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    912
  47. DataportKultur

    DataportKultur

    Joined:
    May 5, 2022
    Posts:
    3
    Hi there,

    I started with a Sync Controller to sync a saved json File to a webspace. For now I tried a localhost with xampp+mysql but I get a 404 error. What am I missing?

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using TMPro;
    4.  
    5. public class ES3CloudManager : MonoBehaviour
    6. {
    7.     // The Text of the "Save and Upload" button, so we can use it to
    8.     // show the upload status.
    9.     public TextMeshProUGUI buttonText;
    10.  
    11.     // Replace these with your own URL and API Key, as provided when you set-up ES3Cloud:
    12.     // https://docs.moodkie.com/easy-save-3/es3-guides/saving-loading-files-to-web-using-es3cloud/
    13.     private string url = "localhost/ES3Cloud.php";
    14.     private string apiKey = "hereMyAPIKey";
    15.    
    16.     private string filePath;
    17.    
    18.      // * This is called when the scene first loads.
    19.      // * We'll use this to download our file from the server if it exists.
    20.    
    21.     private void Awake()
    22.     {
    23.         //  JSON Dateiname und Einträge aus anderem Script abrufen
    24.         filePath = GetComponent<InputHandler>().filename;
    25.        
    26.         StartSync();
    27.     }
    28.    
    29.    
    30.     IEnumerator Sync()
    31.     {
    32.         // Create an ES3Cloud object with our URL and API key.
    33.         var cloud = new ES3Cloud(url, apiKey);
    34.  
    35.         // Change the button text to show we're uploading.
    36.         buttonText.text = "Uploading...";
    37.  
    38.         // Upload the default file to the server.
    39.         yield return StartCoroutine(cloud.Sync(Application.persistentDataPath + "/" + filePath, "root", ""));
    40.         // Now check that no errors occurred.
    41.         if(cloud.isError)
    42.         {
    43.             buttonText.text = "Error! Sync";
    44.             Debug.LogError(cloud.error);
    45.         }
    46.         else
    47.             // Now change the button to show that the data has been uploaded successfully.
    48.             buttonText.text = "Uploaded!";
    49.     }
    50.    
    51.     public void StartSync()
    52.     {
    53.         StartCoroutine(Sync());
    54.     }
    55.  
    56. }
    57.  
     
  48. JoelAtMoodkie

    JoelAtMoodkie

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

    A 404 error would indicate an issue with your server rather than at Easy Save’s end, as it’s the server indicating that the path you’ve provided doesn’t exist.

    One thing to try: your URL doesn’t begin with the protocol (I.e http:// or https://) which may be required by your server depending on configuration.

    All the best,
    Joel
     
    andreiagmu likes this.
  49. _DS_1

    _DS_1

    Joined:
    Sep 6, 2016
    Posts:
    17
    Hello! It would be really helpful to have an Assembly Definition for Easy Save, a lot of assets have one and it help me have organized code.
     
    andreiagmu likes this.
  50. JoelAtMoodkie

    JoelAtMoodkie

    Joined:
    Oct 18, 2009
    Posts:
    912
    Hi there, and thanks for the suggestion.

    Unfortunately we can't currently add one as default it would break the projects of previous users who began using Easy Save before assembly definitions existed. However, you can add your own if you wish, in the same way that you would add it for your own classes.

    We're currently looking at creating the next major version of Easy Save, at which point we would definitely be looking to use assembly definitions.

    All the best,
    Joel
     
    andreiagmu likes this.