回放事件的记录
创建 SavedManager 类 用来记录要发生的事情
public class SavedManager : MonoBehaviour
{
static int nums = 0;
private static SavedManager instance = new SavedManager();
public static SavedManager Instance()
{
return instance;
}
public static bool replay = false;
public static bool Record = false;
long timeAll = 0; // 记录的全部时长
public string timeNow = "0"; // 当前的时长
/// <summary>
/// 计时器
/// </summary>
private static Stopwatch stopwatch = new Stopwatch();
String path;
public void Awake()
{
if (instance == null)
{
instance = this;
}
}
// 记录事件
public void WriteMessage(string msg)
{
if (Record)
{
msg = stopwatch.ElapsedMilliseconds + ":" + msg;
using (FileStream fs = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine("{0}\n", msg, DateTime.Now);
sw.Flush();
// sw.Close();
}
}
}
}
// 开始录制
public void LogStartRecord()
{