I was following the steps of a tutorial on how to save and load game but apparently I got error creating a “game” list, I do not know what the problem is if you can help me.
Console:
The type or namespace name `Game’ could not be found. Are you missing an assembly reference?
Code Unity 5:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public static class SaveLoad {
// Que solo haya un archivo de partida guardada y no varios
public static List savedGames = new List();
public static void Save () {
savedGames.Add (Game.current);
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + “/SavedGames.gd”);
bf.Serialize (file, SaveLoad.savedGames);
file.Close ();
}
public static void Load () {
if ( File.Exists (Application.persistentDataPath + “/SavedGames.gd” ) ) {
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Open (Application.persistentDataPath + “/SavedGames.gd”, FileMode.Open);
SaveLoad.savedGames = (List )bf.Deserialize (file);
file.Close ();
}
}
}