Net-Game/Library/PackageCache/com.unity.test-framework.performance@fb0dc592af8b/Runtime/ResourcesLoader.cs
2025-03-28 08:33:16 -04: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;
}
}
}