Save-O-Magic

Have your ever made a game and said, “I wish there was an easier way to save all this stuff”. Or “I hate writing line after line saving everything in the playerprefs classes”. Well fear no more, Save-O-Magic is here…well sort of.

SAVE-O-MAGIC

Saving your data has never been easier with the Save-O-Magic(SOM). SOM will allow you to neatly put all your variables into one static class for easy access between all your scripts. SOM is written in C# and is able to be used for mobile, desktop and web locally. SOM uses Unity’s built in Player Prefs class allowing you to save floats, int, bools, doubles, and List’s of that same types.
SOM key feature is one line access to all your saving and loading needs. No more writing line after line of setting and getting information. That is all handled automatically for you. Just simply call Save() and Load() and you will have all your data saved and loaded accordingly.

Key Features:

  • Auto save and load variables
  • No tedious amount of code to save and load, one line is all you need.
  • Indexing save slots for multiple save files
  • Lists can be saved
  • Full source code included
  • Peace of mind knowing you don’t have to make another save\load script
  • Handy editor to quickly view all your saved variables to make on the fly changes

SOM is a work in progress but with your help I know I can make it so you will never have to thinking about saving variables ever again. SOM will come with examples to help you get started, but it’s really that easy to get everything up and running.

Available variable types

  • float
  • bool
  • double
  • string
  • int
  • Vector2
  • Vector3
  • List
  • List
  • List
  • List
  • List

Examples:
First thing you need to do is use the dedicated script to put all your saved values to.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public static class Variables {
    // this will not save
    public static double health = 100;
    // this will save
    public static Vector3 maxHealth;
    public static int currentLevel = 1;
    public static int currentExperience = 0;
    public static int experienceToLevel = 500;
    public static List<bool> spellsUnlocked = new List<bool>();
    public static List<double> inventorySlots = new List<double>();
    public static Vector2 guiPlacement;
}

Loading

void Start () {
        SavedVariables.Load();
	}

Saving

void Start () {
        SavedVariables.Save();
	}

Loading an index

void Start () {
        SavedVariables.Load(2);
	}

Saving to an index

void Start () {
        SavedVariables.Save(2);
	}

Just a quick shot of the editor and a testing script to display the saved values.

Very intriguing but a few questions come to mind.

  1. How does Save-O-Magic handle saving serializable classes, like this bad boy:
using System;

public class HealthSystem : Monobehaviour
{
    public int HP;
    public int MaxHP;
    public GameObject DeathEffect;
    public AudioClip DamageSound;

    // SNIP: methods, not necessary for this question.
}

2: On that note, how does Save-O-Magic handle at-the-moment state saves? By state saves, I’m referring to every aspect of every entity in the current scene, as well as the currently loaded scene itself. This is useful for making ‘quick-saves’ which are absolutely vital to mobile and handheld games.

SOM works on a pretty limited basis right now, the variables types I listed are the only ones that it can handle at the moment. In your health example it can save the hp and max hp by putting those values into the dedicated script(Variables.cs), then you would reference them to your player. As far as the GameObject and AudioClip, SOM will not save those types, but I am unsure why they would be save in the first place.

For question 2, SOM cannot save every aspect of the scene unless you have a variable associated with it in the dedicated script. So if you’re placing buildings down and need to save their location then your going to have to wait until I have figured out how to get the transform and vector information to pass correctly into everything.

But SOM works on the premise of put all your static variables into one script, then it will auto generated save information for it. I am working to bring it more variable types, and way’s to pass in variables from any script into the auto save feature.

Thanks for the questions as it let’s me figure out more of what people are looking for and what they want to use it for.

I just finished up the Vector 2, and 3 saves. So now you can save Vector 2, 3 values as well as the others.