public void Guardar() { BinaryFormatter fb = new BinaryFormatter(); FileStream Expediente = File.Create(Application.persistentDataPath + "/Datos.d"); DatosDeJuego Datos = new DatosDeJuego(); Datos.numeroEntero = numeroEntero; Datos.numeroDecimal = numeroDecimal; Datos.texto = texto; fb.Serialize(Expediente, Datos); Expediente.Close(); print("Guarde"); }
public void Cargar() { if (File.Exists(Application.persistentDataPath + "/Datos.d")) { BinaryFormatter fb = new BinaryFormatter(); FileStream Expediente = File.OpenRead(Application.persistentDataPath + "/Datos.d"); DatosDeJuego Datos = new DatosDeJuego(); Datos = fb.Deserialize(Expediente) as DatosDeJuego; numeroEntero = Datos.numeroEntero; numeroDecimal = Datos.numeroDecimal; texto = Datos.texto; print("Cargo"); } else { print("No existe archivo"); } }