Coder Social home page Coder Social logo

savemanager's Introduction

SaveManager

A simple, yet powerful binary serializer for persisting game data in Unity, written in C#.

We used this serializer for Poi to manage all saved game data with multiple save profiles and complex data storage classes.

We implemented the IGameSave interface for Xbox One and Wii U by creating XboxOneSaveManager.cs and WiiUSaveManager.cs (tested on dev kits for both). This allowed us to ignore Unity's PlayerPrefs API entirely, as it's not an ideal solution for saving data.

This solution also supports Steam Cloud without having to write a single additional line of code (via Steam Auto-Cloud).

Example Usage

// A sample data class to serialize
[Serializable]
public class SaveData {
	public int ID;
	public string Name;
	
	// Lists work too, for example, to make your own "PlayerPrefs"
	public List<KeyValuePair<string, int>> Flags = new List<KeyValuePair<string, int>>();
	
	// Etc... (safe to add new fields here, even if the file has already been serialized)
}

// It's a good idea to keep a reference to the manager somewhere in your project (ie: Singleton).
// For Poi, we had a small "GameSaveManager" Singleton wrapper which managed multiple save files.
StandaloneSaveManager manager = new StandaloneSaveManager();

// If the file doesn't exist, this will simply return a default SaveData instance
MySaveData data = manager.BinaryDeserialize<SaveData>("save.dat");

// Set some arbitrary data
data.Name = "Hello, World.";

// Write to disk
saveManager.BinarySerialize("save.dat", data);

savemanager's People

Contributors

ewersp avatar

Watchers

James Cloos avatar Mei Shijie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.