this is error: Assets/Scripts/LoadGame.cs(48,2): error CS0246: The type or namespace name `serializable’ could not be found. Are you missing a using directive or an assembly reference?
I want to know what’s wrong.
using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
public class LoadGame : MonoBehaviour
{
public Turn turn;
public void Save()
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Create(Application.persidentDataPath + "/playerInfo.dat");
PlayerData data = new PlayerData();
turn.Cash = Cash;
bf.Serialize(file, data);
file.Close();
}
public void Load()
{
if (File.Exists(Application.persidentDataPath + "/playerInfo.dat"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persidentDataPath + "/playerInfo.dat", FileMode.Open);
file.Close();
Cash = turn.Cash;
}
}
}
[serializable]
class PlayerData
{
public int Cash;
}
isn't it
– gjfSerializable? also, it looks like the closing brace on line 9 shouldn't be there...