Exemple #1
0
    public static void SavePlayer(Personnage j)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        string path = Application.persistentDataPath + "/" + j.nom + ".fun";

        Debug.Log("save ici : " + path);
        FileStream          stream = new FileStream(path, FileMode.Create);
        DataToSaveForPlayer data   = new DataToSaveForPlayer(j);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Exemple #2
0
    public static DataToSaveForPlayer LoadPlayer(string nom)
    {
        string path = Application.persistentDataPath + "/" + nom + ".fun";

        if (File.Exists(path))
        {
            BinaryFormatter     formatter = new BinaryFormatter();
            FileStream          stream    = new FileStream(path, FileMode.Open);
            DataToSaveForPlayer data      = formatter.Deserialize(stream) as DataToSaveForPlayer;
            stream.Close();
            return(data);
        }
        else
        {
            return(null);
        }
    }