I don’t know if it’s because I have a mac or if I messed up somewhere, but this script isn’t working for some reason. I get an error that says Unexpected Symbol on the 20th line of code (20, 24).
Here’s my code:
using UnityEngine;
using System.Collections;
using System;
using System.Text;
using System.IO;
public class SaveGame : MonoBehaviour {
String path;
String fileName;
// Use this for initialization
void Start () {
fileName = "/gameSave.txt";
}
// Update is called once per frame
void Update () {
path = Application.dataPath + fileName;
using (FileStream fs = File.Create(path)){
AddText(fs, "Your Game is Saved");
}
private static void AddText(FileStream fs, string value){
byte[] info = new UTF8Encoding(true).GetBytes(value);
fs.Write(info, 0, info.Length);
}
}