A game about forced loneliness, made by TACStudios
1using System; 2using Unity.PerformanceTesting.Data; 3using Unity.PerformanceTesting.Runtime; 4using UnityEngine; 5#if USE_CUSTOM_METADATA 6using com.unity.test.metadatamanager; 7#endif 8 9namespace Unity.PerformanceTesting 10{ 11 /// <summary> 12 /// Helper class to retrieve metadata information about player settings and hardware. 13 /// </summary> 14 public static class Metadata 15 { 16 /// <summary> 17 /// Gets hardware information. 18 /// </summary> 19 /// <returns>Hardware information.</returns> 20 public static Hardware GetHardware() 21 { 22 return new Hardware 23 { 24 OperatingSystem = SystemInfo.operatingSystem, 25 DeviceModel = SystemInfo.deviceModel, 26 DeviceName = SystemInfo.deviceName, 27 ProcessorType = SystemInfo.processorType, 28 ProcessorCount = SystemInfo.processorCount, 29 GraphicsDeviceName = SystemInfo.graphicsDeviceName, 30 SystemMemorySizeMB = SystemInfo.systemMemorySize 31 }; 32 } 33 34 /// <summary> 35 /// Sets player settings. 36 /// </summary> 37 /// <param name="run">Run used to set settings.</param> 38 public static void SetPlayerSettings(Run run) 39 { 40 run.Player.Vsync = QualitySettings.vSyncCount; 41 run.Player.AntiAliasing = QualitySettings.antiAliasing; 42 run.Player.ColorSpace = QualitySettings.activeColorSpace.ToString(); 43 run.Player.AnisotropicFiltering = QualitySettings.anisotropicFiltering.ToString(); 44 run.Player.BlendWeights = QualitySettings.skinWeights.ToString(); 45 #if UNITY_2022_2_OR_NEWER 46 run.Player.ScreenRefreshRate = (int)Math.Round(Screen.currentResolution.refreshRateRatio.value); // casting to int and rounding to ensure backwards compatibility with older package versions 47 #else 48 run.Player.ScreenRefreshRate = Screen.currentResolution.refreshRate; 49 #endif 50 run.Player.ScreenWidth = Screen.currentResolution.width; 51 run.Player.ScreenHeight = Screen.currentResolution.height; 52 run.Player.Fullscreen = Screen.fullScreen; 53 run.Player.Batchmode = Application.isBatchMode; 54 run.Player.Development = Application.isEditor || Debug.isDebugBuild; 55 run.Player.Platform = Application.platform.ToString(); 56 run.Player.GraphicsApi = SystemInfo.graphicsDeviceType.ToString(); 57 } 58 59 /// <summary> 60 /// Loads run from resources. 61 /// </summary> 62 /// <returns></returns> 63 public static Run GetFromResources() 64 { 65 var run = ResourcesLoader.Load<Run>(Utils.TestRunInfo, Utils.PlayerPrefKeyRunJSON); 66 SetRuntimeSettings(run); 67 68 return run; 69 } 70 71 /// <summary> 72 /// Sets runtime player settings on a run. 73 /// </summary> 74 /// <param name="run">Run used to set settings.</param> 75 public static void SetRuntimeSettings(Run run) 76 { 77 run.Hardware = GetHardware(); 78 SetPlayerSettings(run); 79 run.TestSuite = Application.isPlaying ? "Playmode" : "Editmode"; 80#if USE_CUSTOM_METADATA 81 SetCustomMetadata(run); 82#endif 83 } 84 85#if USE_CUSTOM_METADATA 86 private static void SetCustomMetadata(Run run) 87 { 88 var customMetadataManager = new CustomMetadataManager(run.Dependencies); 89 // This field is historically not used so we can safely store additional string delimited 90 // metadata here, then parse the metadata values out on the SQL side to give us access 91 // to additional metadata that would normally require a schema change, or a property back field 92 run.Player.AndroidTargetSdkVersion = customMetadataManager.GetCustomMetadata(); 93 } 94#endif 95 } 96}