备份CatanBuilding瘦身独立工程
This commit is contained in:
65
Assets/Scripts/AOTScripts/GpuEvaluation.cs
Normal file
65
Assets/Scripts/AOTScripts/GpuEvaluation.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
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<TextAsset>("gpudata");
|
||||
handle.WaitForCompletion();
|
||||
_devdatas = Newtonsoft.Json.JsonConvert.DeserializeObject<GpuData[]>(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
|
||||
}
|
||||
Reference in New Issue
Block a user