protected override void UI(int id) { if (GUILayout.Button("Update")) { HardwareInfo.Get(); } GUILayout.Space(5); ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true); GUILayout.BeginVertical(); GUILayoutExtensions.LabelWithSpace("Device Type: " + HardwareInfo.deviceType, -8); GUILayoutExtensions.LabelWithSpace("Operation System: " + HardwareInfo.operatingSystem, -8); GUILayoutExtensions.LabelWithSpace("Unity Version: " + HardwareInfo.unityVersion, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device: " + HardwareInfo.graphicsDeviceName, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device API: " + HardwareInfo.graphicsDeviceVersion, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device ID: " + HardwareInfo.graphicsDeviceID, -8); GUILayoutExtensions.LabelWithSpace("Graphics Memory Size: " + HardwareInfo.graphicsMemorySize, -8); GUILayoutExtensions.LabelWithSpace("Supported Shader Level: " + HardwareInfo.graphicsShaderLevel, -8); GUILayoutExtensions.LabelWithSpace("CPU: " + HardwareInfo.processorType, -8); GUILayoutExtensions.LabelWithSpace("CPU Cores Count (Threads Count): " + HardwareInfo.processorCount, -8); GUILayoutExtensions.LabelWithSpace("CPU Current Frequency: " + HardwareInfo.processorFrequency + "Hz", -8); GUILayoutExtensions.LabelWithSpace("RAM: " + HardwareInfo.systemMemorySize, -8); GUILayoutExtensions.LabelWithSpace("Maximum Texture Size: " + HardwareInfo.maxTextureSize, -8); GUILayoutExtensions.LabelWithSpace("Non-Power-Of-Two Texture Support: " + HardwareInfo.npotSupport, -8); GUILayoutExtensions.LabelWithSpace("ComputeShaders: " + HardwareInfo.supportsComputeShaders, -8); GUILayoutExtensions.LabelWithSpace("RenderTextures: " + true, -8); GUILayoutExtensions.LabelWithSpace("3DTextures: " + HardwareInfo.supports3DTextures, -8); GUILayoutExtensions.LabelWithSpace("Graphics Multithreading: " + HardwareInfo.graphicsMultiThreaded, -8); DrawSupportedFormats <RenderTextureFormat>(HardwareInfo.RenderTextureFormats, "RenderTexture"); DrawSupportedFormats <TextureFormat>(HardwareInfo.TextureFormats, "Texture"); GUILayout.Space(10); GUILayout.EndVertical(); GUILayout.EndScrollView(); }
private void DrawSupportedFormats <T>(List <T> formats, string prefix = "null") where T : struct, IConvertible { if (!typeof(T).IsEnum) { throw new ArgumentException("Only 'enum' types as T allowed!"); } foreach (var format in formats) { var supports = false; var supportState = "NULL"; try { // NOTE : So, that's why i hate "bruteforce" solutions... if (typeof(T) == typeof(RenderTextureFormat)) { var f = (RenderTextureFormat)Enum.ToObject(typeof(RenderTextureFormat), format); supports = SystemInfo.SupportsRenderTextureFormat(f); } else if (typeof(T) == typeof(TextureFormat)) { var f = (TextureFormat)Enum.ToObject(typeof(TextureFormat), format); supports = SystemInfo.SupportsTextureFormat(f); } else { throw new NotImplementedException("Unsupported format!"); } supportState = HardwareInfo.Supports(supports); } catch (Exception ex) { supports = false; supportState = ex.GetType().Name; } GUILayoutExtensions.LabelWithSpace(string.Format("{0}.{1}: {2}", prefix, format, supportState), -8); } }
private void DrawSupportedFormats <TFormatType>(Dictionary <TFormatType, HardwareInfo.SupportState> formats, string prefix = "null") where TFormatType : struct, IConvertible { if (!typeof(TFormatType).IsEnum) { throw new ArgumentException("Only 'enum' types as T allowed!"); } if (formats == null || formats.Count == 0) { GUILayoutExtensions.HorizontalBoxed("", GUISkin, () => { GUILayoutExtensions.LabelWithFlexibleSpace("No Data!", "No Info!"); }); return; } foreach (var kvp in formats) { var format = kvp.Key; var supportState = kvp.Value; var tempColor = GUI.color; var actualColor = HardwareInfo.SupportStateToColor(supportState); GUILayoutExtensions.DrawWithColor(() => { GUILayoutExtensions.HorizontalBoxed("", GUISkin, () => { GUILayoutExtensions.DrawWithColor(() => { GUILayoutExtensions.LabelWithFlexibleSpace(string.Format("{0}.{1}", prefix, format), supportState.ToString()); }, tempColor); }); }, actualColor); } }
protected override void Awake() { base.Awake(); HardwareInfo.Get(); }
protected override void UI(int id) { GUILayoutExtensions.VerticalBoxed("Controls: ", GUISkin, () => { GUILayoutExtensions.VerticalBoxed("", GUISkin, () => { if (GUILayout.Button("Update")) { HardwareInfo.Get(); } }); }); GUILayoutExtensions.SpacingSeparator(); ScrollPosition = GUILayout.BeginScrollView(ScrollPosition, false, true); GUILayoutExtensions.VerticalBoxed("Overall summary: ", GUISkin, () => { GUILayoutExtensions.VerticalBoxed("", GUISkin, () => { GUILayoutExtensions.LabelWithSpace("Device Type: " + HardwareInfo.deviceType, -8); GUILayoutExtensions.LabelWithSpace("Operation System: " + HardwareInfo.operatingSystem, -8); GUILayoutExtensions.LabelWithSpace("Unity Version: " + HardwareInfo.unityVersion, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device: " + HardwareInfo.graphicsDeviceName, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device API: " + HardwareInfo.graphicsDeviceVersion, -8); GUILayoutExtensions.LabelWithSpace("Graphics Device ID: " + HardwareInfo.graphicsDeviceID, -8); GUILayoutExtensions.LabelWithSpace("Graphics Memory Size: " + HardwareInfo.graphicsMemorySize, -8); GUILayoutExtensions.LabelWithSpace("Supported Shader Level: " + HardwareInfo.graphicsShaderLevel, -8); GUILayoutExtensions.LabelWithSpace("CPU: " + HardwareInfo.processorType, -8); GUILayoutExtensions.LabelWithSpace("CPU Cores Count (Threads Count): " + HardwareInfo.processorCount, -8); GUILayoutExtensions.LabelWithSpace("CPU Current Frequency: " + HardwareInfo.processorFrequency + "Hz", -8); GUILayoutExtensions.LabelWithSpace("RAM: " + HardwareInfo.systemMemorySize, -8); GUILayoutExtensions.LabelWithSpace("Maximum Texture Size: " + HardwareInfo.maxTextureSize, -8); GUILayoutExtensions.LabelWithSpace("Non-Power-Of-Two Texture Support: " + HardwareInfo.npotSupport, -8); GUILayoutExtensions.LabelWithSpace("RenderTextures: " + true, -8); GUILayoutExtensions.LabelWithSpace("Graphics Multithreading: " + HardwareInfo.graphicsMultiThreaded, -8); GUILayoutExtensions.LabelWithSpace("Supports ComputeShaders: " + HardwareInfo.supportsComputeShaders, -8); GUILayoutExtensions.LabelWithSpace("Supports 3DTextures: " + HardwareInfo.supports3DTextures, -8); GUILayoutExtensions.LabelWithSpace("Supports 2DArrayTextures: " + HardwareInfo.supports2DArrayTextures, -8); GUILayoutExtensions.LabelWithSpace("Supports 3DRenderTextures: " + HardwareInfo.supports3DRenderTextures, -8); GUILayoutExtensions.LabelWithSpace("Supports CubemapArrayTextures: " + HardwareInfo.supportsCubemapArrayTextures, -8); GUILayoutExtensions.LabelWithSpace("Supports RawShadowDepthSampling: " + HardwareInfo.supportsRawShadowDepthSampling, -8); GUILayoutExtensions.LabelWithSpace("Supports MotionVectors: " + HardwareInfo.supportsMotionVectors, -8); GUILayoutExtensions.LabelWithSpace("Supports RenderToCubemap: " + HardwareInfo.supportsRenderToCubemap, -8); GUILayoutExtensions.LabelWithSpace("Supports ImageEffects: " + HardwareInfo.supportsImageEffects, -8); GUILayoutExtensions.LabelWithSpace("Supports HardwareQuadTopology: " + HardwareInfo.supportsHardwareQuadTopology, -8); GUILayoutExtensions.LabelWithSpace("Supports 32bitsIndexBuffer: " + HardwareInfo.supports32bitsIndexBuffer, -8); GUILayoutExtensions.LabelWithSpace("Supports SparseTextures: " + HardwareInfo.supportsSparseTextures, -8); GUILayoutExtensions.LabelWithSpace("Supports AsyncCompute: " + HardwareInfo.supportsAsyncCompute, -8); GUILayoutExtensions.LabelWithSpace("Supports GPUFence: " + HardwareInfo.supportsGPUFence, -8); GUILayoutExtensions.LabelWithSpace("Supports AsyncGPUReadback: " + HardwareInfo.supportsAsyncGPUReadback, -8); GUILayoutExtensions.SpacingSeparator(); }); }); GUILayoutExtensions.SpacingSeparator(); GUILayoutExtensions.VerticalBoxed("Render Texture support summary: ", GUISkin, () => { GUILayoutExtensions.VerticalBoxed("", GUISkin, () => { DrawSupportedFormats <RenderTextureFormat>(HardwareInfo.RenderTextureFormats, "RenderTexture"); GUILayoutExtensions.SpacingSeparator(); }); }); GUILayoutExtensions.SpacingSeparator(); GUILayoutExtensions.VerticalBoxed("Texture support summary: ", GUISkin, () => { GUILayoutExtensions.VerticalBoxed("", GUISkin, () => { DrawSupportedFormats <TextureFormat>(HardwareInfo.TextureFormats, "Texture"); GUILayoutExtensions.SpacingSeparator(); }); }); GUILayoutExtensions.SpacingSeparator(); GUILayout.EndScrollView(); }