HKI Core
SystemInfo.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using UnityEngine.UI;
3 using System.IO;
4 using System.Diagnostics;
5 
6 namespace HKI.Core.Debuging
7 {
11  public class SystemInfo : MonoBehaviour
12  {
13  // Public variables
14  [SerializeField] Text ProcessText = null;
15  [SerializeField] Text PathText = null;
16  [SerializeField] Text OSText = null;
17  [SerializeField] Text ProcessorText = null;
18  [SerializeField] Text GpuText = null;
19  [SerializeField] Text APIText = null;
20  [SerializeField] Text DisplayText = null;
21 
22  Resolution oldResolution;
23 
24  // Awake function
25  void Awake()
26  {
27  if(ProcessText != null)
28  ProcessText.text = Process.GetCurrentProcess().ProcessName;
29 
30  if(PathText != null)
31  PathText.text = Path.GetFullPath(Application.dataPath + "/../").ToString();
32 
33  if(OSText != null)
34  OSText.text = UnityEngine.SystemInfo.operatingSystem;
35 
36  if(ProcessorText != null)
37  ProcessorText.text = UnityEngine.SystemInfo.processorType + " [" + UnityEngine.SystemInfo.processorCount.ToString() + " Threads] [" + UnityEngine.SystemInfo.systemMemorySize.ToString() + " MB]";
38 
39  if(GpuText != null && APIText != null)
40  {
41  GpuText.text = UnityEngine.SystemInfo.graphicsDeviceName + " [" + UnityEngine.SystemInfo.graphicsMemorySize.ToString() + " MB]";
42  APIText.text = "[API: " + UnityEngine.SystemInfo.graphicsDeviceVersion + "] [Multi-Threaded: " + UnityEngine.SystemInfo.graphicsMultiThreaded.ToString() + "]";
43  }
44 
45  if(DisplayText != null)
46  {
47  oldResolution = Screen.currentResolution;
48  DisplayText.text = Screen.currentResolution.ToString() + " [" + Screen.dpi + " dpi] [" + (Screen.fullScreen ? "Fullscreen]" : "Windowed]");
49  }
50  }
51 
52  // Interface function
53  public void UpdateInfo()
54  {
55  Resolution currentResolution = Screen.currentResolution;
56 
57  // Only screen resolution can change
58  if (DisplayText != null && (oldResolution.width != currentResolution.width || oldResolution.height != currentResolution.height || oldResolution.refreshRate != currentResolution.refreshRate))
59  DisplayText.text = Screen.currentResolution.ToString() + " [" + Screen.dpi + " dpi] [" + (Screen.fullScreen ? "Fullscreen]" : "Windowed]");
60  }
61  }
62 }
This MonoBehaviour fetches and updates the UI of the DebugSystem/Console with the system information...
Definition: SystemInfo.cs:11