Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[RELEASED] Auto Save System

Discussion in 'Made With Unity' started by DexRobinson, Apr 7, 2014.

  1. DexRobinson

    DexRobinson

    Joined:
    Jul 26, 2011
    Posts:
    594
    Link to asset store: Auto Magic
    Price: $15 USD

    How many times have you made a game only to get to the saving part of it and had to write out line after line using PlayerPref.Set whatever. Then when there is other variables you add in later you have to go back and write more save and load lines. There is now a SIMPLE and EASY way to save all your variables.

    I give you...Auto-Magic! With the Auto-Magic save system you now NEVER have to worry about writing a save system again. Just write all your variables into a static class that is provided for you and then when you need to save or load you just have to make one call to the save or load function. It's that simple. No more manually writing out lines of code again.


    [THE OLD WAY]
    Example 1: John has 10 variables he wants to save for his game. Here is a sample of what John's code would look like using the standard way...
    Code (csharp):
    1.  
    2. public class Saving : MonoBehaviour
    3. {
    4.     void Save()
    5.     {
    6.         PlayerPrefs.SetInt("variable1", 1);
    7.         PlayerPrefs.SetInt("variable2", 2);
    8.         PlayerPrefs.SetInt("variable3", 3);
    9.         PlayerPrefs.SetInt("variable4", 4);
    10.         PlayerPrefs.SetInt("variable5", 5);
    11.         PlayerPrefs.SetInt("variable6", 6);
    12.         PlayerPrefs.SetInt("variable7", 7);
    13.         PlayerPrefs.SetInt("variable8", 8);
    14.         PlayerPrefs.SetInt("variable9", 9);
    15.     }
    16.  
    17.     void Load()
    18.     {
    19.         int var1 = PlayerPrefs.GetInt("variable1");
    20.         int var2 = PlayerPrefs.GetInt("variable2");
    21.         int var3 = PlayerPrefs.GetInt("variable3");
    22.         int var4 = PlayerPrefs.GetInt("variable4");
    23.         int var5 = PlayerPrefs.GetInt("variable5");
    24.         int var6 = PlayerPrefs.GetInt("variable6");
    25.         int var7 = PlayerPrefs.GetInt("variable7");
    26.         int var8 = PlayerPrefs.GetInt("variable8");
    27.         int var9 = PlayerPrefs.GetInt("variable9");
    28.     }
    29. }
    30.  
    [THE AUTO-MAGIC WAY]
    Same Example as John's using Auto-Magic
    Code (csharp):
    1.  
    2. public static class Variables
    3. {
    4.     public static float variable1 = 0;
    5.     public static float variable2 = 0;
    6.     public static float variable3 = 0;
    7.     public static float variable4 = 0;
    8. }
    9.  
    Code (csharp):
    1.  
    2. public class Saving : MonoBehaviour
    3. {
    4.     void Save()
    5.     {
    6.         SavedVariables.SaveVariables();
    7.     }
    8.  
    9.     void Load()
    10.     {
    11.         SavedVariables.Load();
    12.     }
    13. }
    14.  
    As you can see using Auto-Magic you can greatly increase the speed in which you want to save and load variables. Auto-Magic also allows you to save under multiple locations for games that may have multiple save slots using the same functions as before

    [SAVING MULTIPLE FILES]​

    Code (csharp):
    1.  
    2. public class Saving : MonoBehaviour
    3. {
    4.     int index = 1;
    5.  
    6.     void Save()
    7.     {
    8.         SavedVariables.SaveVariables(index);
    9.     }
    10.  
    11.     void Load()
    12.     {
    13.         SavedVariables.Load(index);
    14.     }
    15. }
    16.  
    $Photo1.jpg



    Auto-Magic also comes with a built in Editor Window that allows you to view all your saved variables. No more guess what a saved variables is or having to write out tedious log code to output what you saved. With the built in editor you can also manipulate data to change or tweak saved data.

    $Photo2.jpg

    $Photo3.jpg


    [LIMITATIONS]​

    While the Auto-Magic is pure awesome saving power, it does have a few set backs. It uses Unity's built in Player Prefs system so XML or any other kind of saving is not going to work unless you write the code yourself to get it too work. Also there is a set amount of types that you can save, which are the following...
    • float
    • double
    • int
    • bool
    • string
    • Vector2
    • Vector3
    • List<int>
    • List<float>
    • List<double>
    • List<string>
    • List<bool>
    • List<Vector2>(version 1.01)
    • List<Vector3>(version 1.01)

    Saving has never been easier to do with Auto-Magic. Weather you are new to unity or have been developing for years, Auto-Magic will make a great addition to your library for each project you do.

    If you have any questions please feel free to email me @ drobinson@taptoongames.com

    Link to asset store: Auto Magic
    Price: $15 USD

    TL;DR = Make static variables, make 1 call to save and load variables, never write another save script EVER!
     
  2. elmar1028

    elmar1028

    Joined:
    Nov 21, 2013
    Posts:
    2,355
    I like it! Might come in handy!

    P.S: Wrong forum bro. It must be moved here.