Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Bayat - Save System - An ultimate data management solution

Discussion in 'Assets and Asset Store' started by hasanbayat, Jan 28, 2020.

  1. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Thanks for testing again ❤️
    I haven't seen that "DXT1 compressed textures not supported ..," error before, isn't that what makes the build fail?

    Not sure about the error though, I'm going to try to build the same scene and see if I get the error on 2018.1, otherwise I'll test on the latest version.
     
  2. f1chris

    f1chris

    Joined:
    Sep 21, 2013
    Posts:
    308
    yes it's probably what's causing the rest to fall out. Can't find that DXT1 texture causing problem.
     
  3. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Unfortunately, no there is no plan for that, but I think I'll add it on the roadmap, cause this feature looks interesting on some specific cases.
    By the way, for your case you can implement it by the system serialization API and storage API which are open and flexible, so you'd be able to easily implement it and add your own features to it.

    For example, you can serialize the data to a string variable, then whenever the users want, you can save that serialized data to a file, or you can use MemoryStream instead of a variable.

    Hope this helps ❤️
     
    Zebbi likes this.
  4. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    The build with Unity 2018.1 for iOS succeeded, using the Saving & Loading Scene Objects scene, I'll try to build with 2019.3 tomorrow maybe to check if there are any errors with it.
     
  5. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Implemented pagination on Create Object Converter window that improves the overall performance and fixed various bugs for creating converters as well, will be included in the upcoming version.

    Annotation 2020-02-23 144902.png
     
    Last edited: Feb 23, 2020
  6. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    The new version is now live on the Asset Store, 1.0.9:

    Notes
    • We're moving out the AssetReferenceResolver out of the Save System folder so it lets you update the package in future easier, so make sure to move out your AssetReferenceResolver before updating to Assets/Resources/Bayat/Core folder (an alert dialog will be displayed once you install the latest version that asks you to move it out automatically)
    • Backup your project before updating and also remove the Save System before importing
    New features
    • Moving Asset Reference Resolver from Plugins/Bayat folder to Resources folder, which makes it easy to update the package in future
    Bug fixes
    • Fixed Unity object null check for ObjectJsonConverter issue
    • Fixed Create Object Converter generating with full type name information instead of its friendly name
    Known Bugs
    • It looks sometimes the Asset Reference Resolver resets its data as reported by a few users, if anyone has more information on it, please let us know, we didn't see this behavior on our side yet
    • We've received some reports that there are some issues around saving Unity objects with additive scenes (multi-scene) with reference
    • We're working on to improve performance for working with larger projects especially on reference resolvers which is currently an issue

    Thanks for staying with us ❤️
     
  7. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Added Auto Save Manager and GameObject Serialization Manager window to make it easy to exclude children or components from serialization:
    Annotation 2020-03-01 184846.png
    Annotation 2020-03-01 184822.png
     
    f1chris likes this.
  8. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    The new version has been submitted, 1.0.24:

    Notes
    • Backup your project before updating and also remove the Save System before importing (if you've modified Default settings inside the plugin folder, then make sure to move them out before deleting or importing too)
    New features
    • Added Remove On Disable option to the AutoSave component to allow you to choose whether to remove the auto save from auto save manager on OnDisable event or not
    • Added Update On Scene Saving to Scene Reference Resolver which lets the Scene Reference Resolver to update and collect dependencies when you're saving the scene (you can disable it anytime on the Scene Reference Resolver component)
    • Added Update On Entering Play Mode to Scene Reference Resolver which lets the Scene Reference Resolver to update and collect dependencies when you're entering the play mode (you can disable it anytime on the Scene Reference Resolver component)
    • Added CustomSettings property to JsonSerializerSettingsPreset
    • Added support for serialization of ScriptableObjects by both reference and value instead of just reference
    • Added Auto Save Manager window that lets you manage the Auto Save component settings through an intuitive interface
    Annotation 2020-03-01 184846.png
    • Added GameObject Serialization Manager window that lets you manage the GameObject Serialization Handler component settings through an intuitive interface
    Annotation 2020-03-01 184822.png

    Bug fixes
    • Fixed Auto Save Manager referencing same Auto Save component multiple times
    • Fixed Vector2Int and Vector3Int properties being saved as floats instead of int
    • Fixed GetFriendlyName issue
    • Fixed PlayFab integration issues
    • Fixed Firebase Realtime Database integration issues
    • Fixed Firebase Cloud Storage integration issues
    • Fixed Default settings preset configuration not reflecting on SaveSystemSettings.DefaultSettings
    • Fixed Asset Reference Resolver referencing assets with invalid Hide Flags and causing build errors
    • Fixed Asset Reference Resolver error on import or reset
    • Fixed PlayerPrefs Storage not storing data without Base64 encoding
    Known Bugs
    • It looks sometimes the Asset Reference Resolver resets its data as reported by a few users, if anyone has more information on it, please let us know, we didn't see this behavior on our side yet
    • There are some issues around saving Unity objects with additive scenes (multi-scene) with reference
    • We're working on to improve performance for working with larger projects especially on reference resolvers which is currently an issue
    • The Rigidbody2D type requires the 'bodyType' property to be set at last so after generating a converter for it, make sure to re-arrange its WriteProperties method to match the `bodyType` order
    • Serializing Dictionary with object key type requires the object to implement TypeConverter in order to deserialize it
    • There are no built-in converters included for Unity types, cause Unity is constantly updating and changing their API, so it also allows you to generate them whenever you want too and modify them to your desire, so if you run into any issues with serializing them, just generate a custom converter and modify it to fit your requirements
    • It looks there is an issue with loading a runtime instantiated object which was previously referenced by Scene Reference Resolver after exiting and entering play mode again, if you have found any more information or you had the same issue, please let us know

    Thanks for staying with us ❤️
     
  9. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    75
    Hello - Can this save an entire scene to a single file? Or do we need to save each object to a separate file?
    Also does it support asynchronous save and load?
     
  10. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hello.
    Thanks for the question ❤️
    You can use the Auto Save feature to save the whole into a single file or using your own scripts or any other way, it is possible.

    It uses Async/Await now, but it is not fully multi-threaded yet, mostly for Unity objects which we're currently working on some ways to maybe apply multi-threading on all, no ETA or promises though,

    Hope this helps.
     
    antsonthetree likes this.
  11. antsonthetree

    antsonthetree

    Joined:
    May 15, 2015
    Posts:
    75
    I purchased it yesterday. So far it seems to do everything I need. Thanks!

    Question: I have a prefab that loads a mesh and texture from an external file during the Start(). There are multiple instances of this prefab in my scene. When I use your save system it saves everything includeing the vertices, normals, uvs etc for each instance of the prefab. This makes for a giant save file. How can I tell the save system to ignore vertex and texture data when saving?

    Update: Basically I just need to save and load prefabs at their positions. I think I can do this with the AssetReferenceResolver to minimize file size, but the documentation just shows how to convert guid to object and back. How do I tell the save system to save the prefab as a guid instead of dumping all of the gameobjects and mesh info to the file?
     
    Last edited: Mar 3, 2020
  12. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    170
    Anyone knows how to create one save file for all scenes in game so i can have several savegame slots to load. Autosavemanager just let you change the identifier at editor, but i need to have one identifier for each savegame slot for all scenes
     
  13. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Thanks for the questions ❤️
    1. Maybe try to use GameObjectSerializationHandler component to exclude the MeshFilter from being serialized, and then when you load back the prefab, load the mesh back from the external file.
    2. Or you can also use this component to only save transform instead of excluding the Mesh components, this would work too.
    You can also only Save the transform component of your GameObjects if they're being referenced by SceneReferenceResolver, if you're instantiating the GameObjects by yourself, you might add them manually to the SceneReferenceResolver using the SceneReferenceResolver.Add(Object) method and then make sure to use the GUID for the next time, this will be handled by the save system too, you can first try all these stuff in the editor and see how it goes.
     
  14. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Thanks for the question ❤️
    I wouldn't recommend doing that, but it is possible.
    I'd suggest you use a directory for this or store them as individual files instead of doing that, because it improves the performance, it is a better practice if you want to manage your data.

    For example, if you store like 2 or 3 scenes data to a single file and want to load it back, the whole file should be loaded to the memory for deserialization and finding out each specific piece of data for the scene, this, as you know, decreases performance and is just a loss at anyway, but by using individual files it gives extra performance and flexibility to you for managing your data, such deleting, backing up and many other.

    So, if you're willing to save slots to a single file you can have a folder for them like "slots/my-slot.dat" and whenever you want to have a list of them, you can use ListAsync method to get a list of them, and you can simply remove them by calling DeleteAsync("slots/my-slot.dat") or DeleteAsync("slots").

    Let me know if you have any other questions, I'd be glad to help.
     
  15. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    170
    Do you mean store each scene in an individual file, check in what scene i am and load the file just for that scene?
     
  16. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Yes, you can have a specific identifier for each scene or use the scene name.
    By the way, you can just use the Auto Save Manager identifier to adjust it per scene, like "scenes/my-scene.dat".
     
  17. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    170
    Ah ok, now i see the sense of using directories with Auto save manager
     
  18. NewMagic-Studio

    NewMagic-Studio

    Joined:
    Feb 25, 2015
    Posts:
    170
    Anyways i need to save all scenes and not just one. If i start the game, progress from dungeon levels 1 to 10, i need to have all the changes made in those 10 scenes saved in one file as i could have started a new game making different levels than in other save. Creating folders its ok if dont let user have completely different saves, like you mention scenes folder as there will be no slots, just one folder with all the scenes in different files. if i create several folders for several slots i would need each folder had the same files of a loaded slot, when i save the loaded savegame in a new slot.
     
  19. iihx232

    iihx232

    Joined:
    Aug 7, 2019
    Posts:
    1
    Hi, i have game with many many object which hide on button. Can i make undo button (unhide this) with help save-system???
     
  20. kristoof

    kristoof

    Joined:
    Aug 26, 2013
    Posts:
    21
    Hey!
    I just bought this for my game, but when I try to run the example scenes my disk goes 100% and my unity freezes.
    Unity 2019.3.2f1, win10, 512gb m.2 pci-e ssd.

    Edit: this only happens when the scene is not added to the build settings.
    Edit2: nop, still happening.
     
    Last edited: Mar 11, 2020
  21. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    I just wanted to address this, that this has been continued on Discord, as well as this one.
     
    kristoof likes this.
  22. ZayLong

    ZayLong

    Joined:
    Jun 2, 2013
    Posts:
    33
    I have an inventory component.

    I save it in scene one using

    await SaveSystemAPI.SaveAsync(targetInventory.name + ".json", targetInventory);

    I then try to load it in scene two using

    targetInventory = await SaveSystemAPI.LoadAsync<Inventory>(targetInventory.name + ".json");

    it works in a weird way.

    It does not load the inventory data onto the object I specify.

    It loads it as a new object called

    "JSON Loaded Inventory Component"

    I have a feeling this is because of the Reference Manager GUIDs being different between scenes for the same gameobject.


    How do I work around this problem?

    Thank you
     
  23. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hello.
    Thanks for the question ❤️
    That's not a problem in the first place, it happens because they're actually 2 different GameObjects, they just share the same components, except you use DontDenstroyOnLoad on it.
    So, you can use LoadIntoAsync instead of LoadAsync, to Load it directly to the GameObject you want, this way it would work.

    But if you're using DontDestroyOnLoad and want to save it without LoadInto, then you need to add the same reference of the object using the same GUID to the next scene too, using the Inventory script itself maybe, the API is public by Scene Reference Manager.

    Hope this helps.
    Thanks.
     
  24. ZayLong

    ZayLong

    Joined:
    Jun 2, 2013
    Posts:
    33
    That worked perfectly, thank you.
     
    hasanbayat likes this.
  25. wwaero

    wwaero

    Joined:
    Feb 18, 2020
    Posts:
    29
    Hello I'm wondering if your plugin is capable of saving this structure into a json save file and reading it back into unity.

    Code (csharp):
    1.  
    2.     public abstract class Unit : NetworkBehaviour
    3.     {
    4.         public List<Ability> abilities; //could have AnotherAbility or BasicAbility classes
    5. }
    6.  
    7. public abstract class Ability : NetworkBehaviour
    8.     {
    9.         public string title;
    10.         public Sprite symbol;
    11.         public bool isAbilityActive;
    12.  
    13.         public abstract void RunAbility(Unit callingUnit);      
    14.     }
    15.  
    16. public abstract InheritedAbility : Ability
    17. {
    18.  
    19. }
    20.  
    21. public class AnotherAbility : InheritedAbility
    22. {
    23.     public float fuel = 10f;
    24.  
    25.     public override void RunAbility(Unit unit)
    26.     {
    27.            //ability function
    28.     }
    29. }
    30.  
    31. public class BasicAbility : Ability
    32. {
    33.       public float energy = 3f;
    34.  
    35.      public override void RunAbility(Unit unit)
    36.      {
    37.              //ability function
    38.       }
    39. }
    40.  
    41.  
     
  26. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi.
    Thanks for the question ❤️
    Yes, that is totally possible with the system, you can learn more about the serialization features here: http://docs.bayat.io/save-system/manual/serialization.html
     
  27. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    22
    Hey, I have a question about your asset before I purchase.

    I simply want to create an encrypted asset bundle in the editor (it doesn't need to be during runtime).

    Then I'll store it on a server.

    From there my game will download the item from the server, store it locally on device (Android, iOS) and then load and decrypt the asset bundle so then it can be used in the game.

    If that's possible, is this a reasonable way to go about securing my asset bundles so users can't simply copy my asset bundles and open them in Unity?

    Thank you!
     
  28. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi, thanks for the question ❤️
    I wouldn't recommend using the Save System for this purpose personally, but it is possible to do it by using its Encryption feature to encrypt your binary data individually, not through serialization process.which might be a time-consuming process for building asset bundles and unpacking them.

    By the way, I would recommend you to directly use C# AES encryption for encrypting asset bundles instead which would be much easier for asset bundles, but if you want to have a data to be serialized and encrypted by the save system and be included inside the asset bundle, then this system would be a good choice for you.

    I hope this addresses your question, thanks.
     
  29. jimmying

    jimmying

    Joined:
    Sep 20, 2017
    Posts:
    22
    Thanks for the response! Yes, I did start looking into the C# AES encryption after posting my question so I'll probably go with that. I'll probably need your asset for the other features in the future though so I'll be sure to pick it up then. Thanks again.
     
    hasanbayat likes this.
  30. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    213
    A few questions-

    1) How do you get the callback for when saving and/or loading is completed?

    2) Can the Serializer be used standalone. To essential achieve the results right before it's saved to disk?

    3) Is there a save-to-memory option?
     
  31. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Thanks for the questions ❤️

    1. You can either use async/await to wait for the completion of the task or subscribe to SaveSystemAPI events
      Annotation 2020-04-13 102255.png
      Code (CSharp):
      1. // Async/Await example
      2.  
      3. public Action saved;
      4.  
      5. // You can also use async on Unity messages
      6. async void Start() {
      7.     await SaveSystemAPI.SaveAsync("test.dat", myData);
      8.    
      9.     // The save is completed now you can invoke an event like below or do whatever else
      10.     this.saved.Invoke();
      11. }
      12.  
      13. async void Save() {
      14.     await SaveSystemAPI.SaveAsync("test.dat", myData);
      15.    
      16.     // The save is completed now you can invoke an event like below or do whatever else
      17.     this.saved.Invoke();
      18. }
    2. Yes, you can either use the Serializer instance available in SaveSystemSettings or SaveSystemSettings.DefaultSettings or SaveSystemSettings.DefaultSerializer to achieve the result prior to saving to disk, or you can manually instantiate a new instance of the serializer class.
    3. Unfortunately, no there isn't, because we didn't see any point to include that without side effects on user control on the process, so now you can directly use the serializer to serialize the data and store into a variable which will be on the Memory, or you can provide a MemoryStream to the serializer API, by the way, let me know if it is a necessary feature to be included, then I'll re-think my approach.
    I hope these address your questions.
     
    MrIconic likes this.
  32. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    814
    Hello, I just bought bayat save system and made some tests. The serialization abilites are amazing! I can simply pass my custom class into it and all stuff serialized properly!
    But I got a question about game save backwards compatibility.
    My game is still under development, so some save class's members can be changed in future, but players already saved the old class inside the save file, when I updated my game to the players, now their receiving class(has the same type with the old save, but may contain more new member variables or fewer variables) is changed, can the loaded data be deserialized into this new class.
    Is there any official suggestions on this topic?
     
  33. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    612
    Hi, thanks for the question and I'm glad you like it ❤️
    You can have some sort of versioning built into the process like you can add a version property to the file metadata and then at the loading phase make sure to load the data based on the correct version and then do the conversion based on the changed class or stuff like that.

    By the way, if you change fields and properties inside a class, like removing or adding new ones won't have any effect on the deserialization, but if you rename a field, the previous name of the field is inside the file, so it won't be deserialized to the new one, a workaround for this is to create a new field whenever you want to rename it and then use Obsolete property on the previous one and then when you're loading the data, get the value from the old variable and set the value for the new one and empty the old one so the new file wouldn't include that.

    Another possible solution would be to create a new class for each different version of your serialization or use JsonProperty and similar attributes to shape a schema for your data.

    These are the ideas I had at the moment, maybe you can find more and better ideas around.
    I hope this helps ❤️
     
  34. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    814
    Hello, I have some issues using bayat saving system:
    I constructed a game save class with a class called player save and several structs to save the player data:

    Code (CSharp):
    1.  
    2. public struct Calender
    3. {
    4.         public int year;
    5.         public int month;
    6.         public int day;
    7. }
    8.  
    9. public struct SaveInfo
    10. {
    11.         public string SaveName;
    12.         public Calender SavedTime;
    13. }
    14.  
    15. public class PlayerSave
    16. {
    17.         public ulong playerID;
    18.         public string characterName;
    19.  
    20.         public Vector3 worldPosition;
    21.         public Quaternion worldRotation;
    22. }
    23.  
    And the GameSave class hold the player save like this:

    Code (CSharp):
    1.  
    2. public class GameSave
    3. {
    4.         public SaveInfo info;
    5.         public Calender inGameTime;
    6.         public PlayerSave player;
    7. }
    8.  
    Then I found the save file will have a ".temp" followed its file name:
    upload_2020-4-24_14-42-44.png
    And when I load these files, the player save is always null.
    Do I have to specify how to serialize the player save class?
    I see that structs can be easily serialized. Really confused here.

    Edit: after some tests, I find it's a custom struct inside a custom struct that got jammed when serializing:
    I've got a custom struct called Calender and another struct called GameSaveInfo.
    The GameSaveInfo struct has a field of Calender to store the time when the game is saved.
    And the GameSaveInfo struct is inside the GameSave class.
    I'm using SaveSystemAPI.SaveAsync(path, gameSave); to save the whole GameSave class
    and us SaveSystemAPI.LoadIntoAsync<GameSave>(file, save); to load.

    Edit2: Found the issue: the serializer cannot serialize custom structs or classes two layers deep inside the saving class. And a dictionary using an int as key and a custom class as value can be saved but cannot be loaded. Is it the limitation of the saving system or I'm doing things wrong?
     
    Last edited: Apr 26, 2020
  35. cranecam

    cranecam

    Joined:
    Nov 25, 2013
    Posts:
    19
    hi there,

    what are the commands to delete all current
    storage (similar to EasySave's Clear Persistent Data Path.)
     
  36. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    332
    It would be really nice to be able to add the autosave component to objects that need to be persistent between scenes, but instead of saving permanently, it could always go to a temporary file. Then, when the user is able to save, all of the temporary saves could be committed to a permanent file. This would be a really convenient way of handling multiscene objects without needed to use DoNotDestroyOnLoad or manually handling them in a list of vars.
     
  37. OscarLeif

    OscarLeif

    Joined:
    Jul 17, 2016
    Posts:
    9
    Not sure if this is the correct place to report issues.
    I'm using this save system but I have some issues when compile for Android platform.
    When I compile using mono everything works fine, when I change to "Il2cpp" and set stripping engine to "low" the project still works fine, but when set stripping engine to medium or high this will fail.
    Not sure where I can send an example.
     
  38. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    332
  39. Nyrio

    Nyrio

    Joined:
    Aug 27, 2019
    Posts:
    1
    I can't for the life of me figure out how to use the Save System asset properly with a WebGL build. Can anybody give me a pointer? The guides mainly deal with the topic of standalone builds. Thanks!
     
  40. Zebbi

    Zebbi

    Joined:
    Jan 17, 2017
    Posts:
    332
    No support for 6 weeks is a bit disappointing
     
  41. yaboo

    yaboo

    Joined:
    Mar 23, 2016
    Posts:
    35
    Can you serialize texture and meshes?
    Like this

    [System.Serializable]
    public class SceneData
    {
    public string name;
    public Texture tex;
    public Mesh mesh;
    public AudioClip audio;
    public VideoClip video;
    }
     
  42. kevdome3000

    kevdome3000

    Joined:
    Jun 9, 2019
    Posts:
    13
    Hey there,

    I recently purchased the Bayat Save System and I have a number of questions but I can't find an email for customer support. Is there one? If so, what is it?
     
  43. Harekelas

    Harekelas

    Joined:
    Feb 3, 2015
    Posts:
    814
    As I've tested, textures can be serialized but very inefficient. Better just save them as png files through unity's API
    I haven't tried meshes, videos or audios. But extract the core information then save the raw info could be more efficient in my opinion. (for example, you can simply save three arrays: the vertices, triangles and uvs of a mesh to save file and reconstruct the mesh when loading)

    And I've never seen developers of this asset come here to answer anything since last time I posted a question.
     
unityunity