|
metadata
Hi everyone.
Surely my problem is silly, but I am new to driving c # and I have reached a dead end.
The point is that the option of Save / Load in my game works perfectly. Both when I play it in Unity, as online here in Kongregate. But when I close the window, reopen the game, and try to load my savegame, there is nothing.
I have the assumption that I should get that save to be stored in browser cookies, but I have no idea how to do it. I leave the script that I used in case you see something that is wrong. I repeat that I go a little blind, so I wouldn't be surprised if I had a big mistake. Really i havent idea what else to do....
> using UnityEngine;
> using System.IO;
> using System.Runtime.Serialization.Formatters.Binary;
>
> public static class SaveSystem
> {
> public static void SaveGame (AlmacenVariables AM)
> {
> BinaryFormatter formatter = new BinaryFormatter();
>
> string path = Application.persistentDataPath + "/player.prueba";
> FileStream stream = new FileStream(path, FileMode.Create);
>
> PlayerData data = new PlayerData(AM);
>
> formatter.Serialize(stream, data);
> stream.Close();
> }
>
> public static PlayerData LoadPlayer ()
> {
> string path = Application.persistentDataPath + "/player.prueba";
> if (File.Exists(path))
> {
> BinaryFormatter formatter = new BinaryFormatter();
> FileStream stream = new FileStream(path, FileMode.Open);
>
> PlayerData data = formatter.Deserialize(stream) as PlayerData;
> stream.Close();
>
> return data;
> }
> else
> {
> Debug.LogError("Save file not found");
> return null;
> }
> }
>
> }
|
|
metadata
|
|
metadata
What was the problem? how did you solve it?
|
|
metadata
I was saving using BinaryFormateer, cause i needed save some bools. But here in Kongregate only works PlayerPrefs, so i have had to change some things, but yeah, now it works!
|