@Mavina
im getting a error for data.text please help
save system:
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
using UnityEngine.UI;
public class SaveSystem : MonoBehaviour {
public static Text charText;
public static int money;
public static int cakeMultiplier;
public static Text TextMoney;
public static int CakesUpgrades;
public static Text Cakes;
public static int DVDSUpgrades;
public static Text DVDS;
public static int dvdMultiplier;
public static int CDSUpgrades;
public static Text CDS;
public static int cdsMultiplier;
public static int VideoGamesUpgrades;
public static Text VideoGames;
public static int videogamesMultiplier;
public void SaveState()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persistentDataPath + "/PlayerData.dat");
PlayerData data = new PlayerData();
data.text = UIInputField.charText.text;
data.money = UpgradeCakes.money;
data.cakeMultiplier = UpgradeCakes.cakeMultiplier;
data.TextMoney = UpgradeCakes.TextMoney.text;
data.Cakes = UpgradeCakes.Cakes.text;
data.CakesUpgrades = UpgradeCakes.CakesUpgrades;
data.DVDSUpgrades = UpgradeCakes.DVDSUpgrades;
data.DVDS = UpgradeCakes.DVDS.text;
data.dvdMultiplier = UpgradeCakes.dvdMultiplier;
data.CDSUpgrades = UpgradeCakes.CDSUpgrades;
data.CDS = UpgradeCakes.CDS.text;
data.cdsMultiplier = UpgradeCakes.cdsMultiplier;
data.VideoGamesUpgrades = UpgradeCakes.VideoGamesUpgrades;
data.VideoGames = UpgradeCakes.VideoGames.text;
data.videogamesMultiplier = UpgradeCakes.videogamesMultiplier;
bf.Serialize(file, data);
file.Close();
}
public void LoadState()
{
if(File.Exists(Application.persistentDataPath + "/PlayerData.dat"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/PlayerData.dat", FileMode.Open);
PlayerData data = (PlayerData) bf.Deserialize(file);
file.Close();
UIInputField.charText.text = data.text;
UpgradeCakes.money = data.money;
UpgradeCakes.cakeMultiplier = data.cakeMultiplier;
UpgradeCakes.TextMoney.text = data.TextMoney;
UpgradeCakes.CakesUpgrades = data.CakesUpgrades;
UpgradeCakes.Cakes.text = data.Cakes;
UpgradeCakes.DVDSUpgrades = data.DVDSUpgrades;
UpgradeCakes.DVDS.text = data.DVDS;
UpgradeCakes.dvdMultiplier = data.dvdMultiplier;
UpgradeCakes.CDSUpgrades = data.CDSUpgrades;
UpgradeCakes.CDS.text = data.CDS;
UpgradeCakes.cdsMultiplier = data.cdsMultiplier;
UpgradeCakes.VideoGamesUpgrades = data.VideoGamesUpgrades;
UpgradeCakes.VideoGames.text = data.VideoGames;
UpgradeCakes.videogamesMultiplier = data.videogamesMultiplier;
}
}
}
[Serializable]
class PlayerData
{
public string charText;
public int money;
public int cakeMultiplier;
public string TextMoney;
public int CakesUpgrades;
public string Cakes;
public int DVDSUpgrades;
public string DVDS;
public int dvdMultiplier;
public int CDSUpgrades;
public string CDS;
public int cdsMultiplier;
public int VideoGamesUpgrades;
public string VideoGames;
public int videogamesMultiplier;
}