using UnityEngine;
using System.Collections;
using System;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;
public static GameControl s_control;
void Awake()
{
//Is there is no current GameControl, make this te current GameControl
if (s_control == null)
{
DontDestroyOnLoad(gameObject);
s_control = this;
}
else if(s_control != this)
{
Destroy(gameObject);
}
if (GameObject.FindGameObjectWithTag("Player"))
{
s_Survival = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerGUISurvival>();
//s_Player = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>();
s_Inventory = GameObject.FindGameObjectWithTag("Player").GetComponent<Inventory>();
}
}
public void Save()
{
//This will create the file
BinaryFormatter bf = new BinaryFormatter();
//Attempt to open a file //FILE NAME OF SAVES
FileStream file = File.Create(Application.persistentDataPath + "/playerInfo.dat");
PlayerData data = new PlayerData();
//Stuff
//We save into the binary formatter, the file and in the file, our data.
bf.Serialize(file, data);
file.Close();
}
public void Load()
{
if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
{
BinaryFormatter bf = new BinaryFormatter();
FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
//Container to pull data out
PlayerData data = (PlayerData)bf.Deserialize(file);
file.Close();
//Stuff
}
}
So this is the code I have, it worked PERFECTLY before, but when I created another script, this error started to appear: " ‘File’ does not contain a definition for ‘Create’ " So I don’t know what Im doing wrong… My unity is Set to PC, LINUX & MAC so it isn’t the problem and its starting to drive me crazy ![]()
Im using latest unity version and Visual Studio