43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using Script.UI;
|
|
using UnityEngine;
|
|
using ZXL.ID;
|
|
|
|
namespace Script
|
|
{
|
|
public class TitleInfo
|
|
{
|
|
public string title;
|
|
public string subject;
|
|
}
|
|
|
|
public class FileManager : SingleManager<FileManager>
|
|
{
|
|
private string dataPath;
|
|
private string titlePath;
|
|
|
|
private TitleInfo titleInfo;
|
|
public TitleInfo GetTitle => titleInfo;
|
|
|
|
public FileManager()
|
|
{
|
|
dataPath = Application.streamingAssetsPath + $"/data{GenerateGlobalID.GenerateIntID()}.txt";
|
|
if (!File.Exists(dataPath))
|
|
{
|
|
var fileStream = File.Create(dataPath);
|
|
fileStream.Dispose();
|
|
}
|
|
|
|
titlePath = Application.streamingAssetsPath + "/title.txt";
|
|
var text = File.ReadAllLines(titlePath);
|
|
titleInfo = new TitleInfo() { title = text[0], subject = text[1] };
|
|
}
|
|
|
|
public void SavePlayerData(string content)
|
|
{
|
|
var text = File.ReadAllText(dataPath);
|
|
File.WriteAllText(dataPath, text + "\n" + content);
|
|
}
|
|
}
|
|
} |