add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
@@ -0,0 +1,56 @@
using System;
using System.IO;
using UnityEngine;
using UnityEngine.UI;
namespace OHM.UnityToolkit
{
public static class PersitantDataUtils
{
public static string GetFullPersitantPath(string subPath)
{
return Application.persistentDataPath + "/" + subPath;
}
public static bool LoadData<T>(string subPath, out T obj)
{
string path = GetFullPersitantPath(subPath);
Debug.Log("Loading " + path);
try
{
if (File.Exists(path))
{
obj = JsonUtility.FromJson<T>(File.ReadAllText(path));
return true;
}
}
catch (Exception e)
{
Debug.LogException(e);
}
obj = default(T);
return false;
}
public static void SaveData<T>(string subPath, T obj)
{
try
{
File.WriteAllText(GetFullPersitantPath(subPath), JsonUtility.ToJson(obj));
}
catch (Exception e)
{
Debug.LogException(e);
}
}
public static void RemoveData(string subPath)
{
if (File.Exists(GetFullPersitantPath(subPath)))
{
File.Delete(subPath);
}
}
}
}