using UnityEngine; using UnityEngine.AddressableAssets; using System.Linq; // using tysdk; public class GpuEvaluation { private class GpuData { public int tier; public string[] keywords; } private static GpuData[] _devdatas; private static GpuData[] DevDatas { get{ if(_devdatas == null) { var handle = Addressables.LoadAssetAsync("gpudata"); handle.WaitForCompletion(); _devdatas = Newtonsoft.Json.JsonConvert.DeserializeObject(handle.Result.text); } return _devdatas; } } public static int? GetTier(string deviceName) { foreach (var device in DevDatas) { var keywords = device.keywords; if (keywords.All(k => deviceName.IndexOf(k) >= 0)) { var info = string.Join(" ", keywords); Debug.Log($"[GpuEvaluation] Found Match Gpu {info} Tier {device.tier}"); #if AGG using(var track = GEvent.TackEvent("GpuEvaluation")) { track.AddContent("record", true); track.AddContent("gpu", deviceName); track.AddContent("tier", device.tier); } #endif return device.tier; } } #if AGG using(var track = GEvent.TackEvent("GpuEvaluation")) { track.AddContent("record", false); track.AddContent("gpu", deviceName); track.AddContent("tier", 1); } #endif return null; } #if UNITY_EDITOR public static int Tier => 3; #else public static int Tier => GetTier(SystemInfo.graphicsDeviceName) ?? 2; #endif }