Esempio n. 1
0
    public void Save(ISaveable data)
    {
        try {
            string json = jsonTraslator.TranslateToJson(data);

            string     destination = Application.persistentDataPath + String.Format("/{0}.dat", data.PathName());
            FileStream file;

            if (File.Exists(destination))
            {
                file = File.OpenWrite(destination);
            }
            else
            {
                file = File.Create(destination);
            }

            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(file, json);
            file.Close();
        } catch (Exception e) {
            Debug.Log(e.Message);
        }
    }