to new git
This commit is contained in:
19
Assets/Scripts/Statistics/Logger.cs
Normal file
19
Assets/Scripts/Statistics/Logger.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
private const string directory = "/Logs/";
|
||||
private const string baseName = "Log#";
|
||||
|
||||
public static void SaveLog<T>(T objToSerialize)
|
||||
{
|
||||
string dir = Application.persistentDataPath + directory;
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
var logName = baseName + (Directory.GetFiles(dir).Length + 1).ToString();
|
||||
string json = JsonUtility.ToJson(objToSerialize);
|
||||
File.WriteAllText(dir + logName, json);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user