UnityGame/Library/PackageCache/com.unity.test-framework.performance/Runtime/ResourcesLoader.cs
2024-10-27 10:53:47 +03:00

25 lines
677 B
C#

using System;
using UnityEngine;
namespace Unity.PerformanceTesting
{
internal static class ResourcesLoader
{
public static T Load<T>(string assetPath, string prefsKey) where T : class
{
try
{
var runResource = Resources.Load<TextAsset>(assetPath.Replace(".json", ""));
var json = Application.isEditor ? PlayerPrefs.GetString(prefsKey) : runResource.text;
var run = JsonUtility.FromJson<T>(json);
return run;
}
catch (Exception e)
{
Debug.LogError(e);
}
return null;
}
}
}