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.