Search Unity

Bayat - Save System - An ultimate data management solution

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

  1. MrIconic

    MrIconic

    Joined:
    Apr 5, 2013
    Posts:
    239
    hasanbayat likes this.
  2. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    Is it possible with this plugin to load all jsons from a sub-directory?
    I want to load all `/worlds` and all `/characters` for example. Each one will be shown in a list to the player, and they can choose which to load.

    I know I could write this in c# myself, just wondering if it's supported directly.
     
  3. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    Yes, the SaveSystemAPI facade class provides methods for listing files in a directory, and then you iterate through them and load them:

    Code (CSharp):
    1. StorageListOptions options = new StorageListOptions() {
    2.     // This will not look into subfolders recursively
    3.     Recurse = false
    4. };
    5.  
    6. // It'll list all the files inside the "worlds" directory, if the current storage is File system, then it'll look inside the Application.persistentDataPath directory for this folder
    7. string[] worlds = await SaveSystemAPI.List("worlds");
    8.  
    9. for (int i = 0; i < files.Length; i++) {
    10.     string world = worlds[i];
    11.     await SaveSystemAPI.LoadAsync<WorldData>(world);
    12. }
    So basically by this, you would be able to get the identifiers to the files or load them by iterating through them, you can also use the Meta Data feature of the Save System to store additional information about a particular data to be loaded individually.
     
  4. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    saawweeet! Thx
     
  5. xiao3286889

    xiao3286889

    Joined:
    Jul 5, 2016
    Posts:
    2
    I like Save System very much, but I have a problem, which is this:
    I use AssetBundle to load the model into the scene, save it with Save System, and then load it again. I found that Mesh was loaded, But Material is not work. How can I load Material from AssetBundle. The save text is as follows.
     

    Attached Files:

  6. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    Usually Unity objects need to be referenced prior to saving either by Asset Reference Manager or Scene Reference Manager, you can check for that through the Manager windows provided for both.

    Please first try to make sure if the Material is referenced by Asset Reference Manager then if it is already referenced, then provide your Save / Load script here or inside a project in which the behavior is reproducible, and then I'll be able to provide more helpful insight.

    Also, do you get any errors during the saving and loading phases? and if possible try to change the data structure for your saving to something smaller and more compact instead of saving Mesh and Material data.
     
  7. xiao3286889

    xiao3286889

    Joined:
    Jul 5, 2016
    Posts:
    2
    Thank you. I tried to call the RefreshDependencies() of the Scene Reference Resolver when the scene was saved. During Load(), it was loaded perfectly. But when I packaged the PC platform, I encountered an error. The error prompted the Scene Reference Resolver script RefreshDependencies() this function.
     
  8. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    The
    RefreshDependencies
    is for Editor only, it is not supposed to be used in Runtime which is in your PC build platform.
    Instead, you should use the buttons provided on the Scene Reference Resolver to fetch the references and keep a track of them, what actually happens beneath is that button makes a call to the
    RefreshDependencies
    and this method fetches the dependencies for the currently active scene and then checks whether the dependencies are referenced if they are not referenced, generates a new GUID for them which points to that specific Unity object reference, and Save System uses that GUID to save and load these Unity objects and restore the data into them instead of instantiating new Unity object in place.

    So in a nutshell you should just make sure the object you're trying to save is included or referenced by the Asset Reference Resolver if it is an Asset or by Scene Reference Resolver if it is a Scene object and you can fetch references through their respective controls and buttons.
     
  9. Tretiak

    Tretiak

    Joined:
    Jan 22, 2018
    Posts:
    49
    Hi i want to read documentations but looks like your page doesnt work, will be online any soon ?
     
  10. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    Sorry for the late response here, you can join our Discord for faster news, the downtime was for the migration of hosting infrastructure.
     
  11. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    The new version is now live, 1.12.30:
    • ✔️ Fixed Connection String Factories not being initialized on AOT/IL2CPP platforms (Now they're using RuntimeInitializeOnLoadMethod to register themselves, third-party storage providers should implement the same method)
    • ✔️ Updated all official integration packages to reflect the Connection String Factory patch (e.g. Steamworks .NET, PlayFab, Firebase, Facepunch Steamworks, ...)
    • ✔️ Fixed 'ScriptableObject' being serialized more than once for the subsequent references
    And check more information from the previous versions in the Changelog.
     
  12. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    The new version is now live, 1.19.0:

    ⭐ New Features ⭐
    ⚡ Improvements & Changes ⚡
    • ⚡ The Auto Save Manager now sorts the Auto Saves based on the hierarchy order, from parent to children, so this way there won't be any more issues with having missing objects from hierarchy
    • ⚡ The Material Properties Resolver now uses the material asset GUID for lookup, so there won't be name collisions during serialization
    • ⚡ The Material Properties Resolver now ignores material instances, and their properties are dynamically fetched
    • ⚡ The MaterialConverter retrieves the properties of a material dynamically through the Shader API instead of using the cached properties in the Material Properties Resolver for Material instances, the referenced Materials are still fetched through the resolver
    ⚙️ Fixed Bugs ⚙️
    • ✔️ Fixed Material Properties Resolver name collision bug when having materials with the same name
    • ✔️ Fixed MeshConverter bug when serializing or deserializing read-only meshes
    • ✔️ Fixed ObjectJsonConverter bug when iterating through properties near the end of the object token
    And check more information from the previous versions in the Changelog.
     
    Elermond likes this.
  13. JohnnyFactor

    JohnnyFactor

    Joined:
    May 18, 2018
    Posts:
    343
    I have a strategy game where I need to "snapshot" the current state of gameplay. I have coroutines, pathfinders, instantiated prefabs, 3rd-party timer plugins, etc. Does your save system address this kind of complexity?

    EDIT: I'm going to edit my question to say, I've since learned that trying to track an enumerator across play sessions is just not a good idea. I'm going to replace all the coroutines and probably some of the plugins too. I'll keep this asset bookmarked.
     
    Last edited: Apr 10, 2022
  14. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    No worries, you can just try it out for free using the trial link in the description of the asset.

    By the way, to implement it in such a complex scenario I would advise you to have some data modeling in mind to control what is being saved and loaded to prevent redundant data from being processed.
     
    Elermond likes this.
  15. TayannaStudios

    TayannaStudios

    Joined:
    Oct 18, 2013
    Posts:
    38
    We have used an asset to set up storage of things like variables and inventory items...Is it still possible to use your plugin with this kind of setup? If so, how would that work?
     
  16. hasanbayat

    hasanbayat

    Joined:
    Oct 18, 2016
    Posts:
    630
    It depends on the plugin you're using, usually, those plugins provide a class that holds all those information to be persistent, so in your case, you can either look through their manual to find out which property/field/class it is to save and store.

    You can also download the trial version of the Save System to play around with i