No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ResourcesLoader.cs 677B

12345678910111213141516171819202122232425
  1. using System;
  2. using UnityEngine;
  3. namespace Unity.PerformanceTesting
  4. {
  5. internal static class ResourcesLoader
  6. {
  7. public static T Load<T>(string assetPath, string prefsKey) where T : class
  8. {
  9. try
  10. {
  11. var runResource = Resources.Load<TextAsset>(assetPath.Replace(".json", ""));
  12. var json = Application.isEditor ? PlayerPrefs.GetString(prefsKey) : runResource.text;
  13. var run = JsonUtility.FromJson<T>(json);
  14. return run;
  15. }
  16. catch (Exception e)
  17. {
  18. Debug.LogError(e);
  19. }
  20. return null;
  21. }
  22. }
  23. }