Quantcast
Channel: Questions in topic: "dll"
Viewing all articles
Browse latest Browse all 706

Problems with using openhardwaremonitorlib.dll with Unity.

$
0
0
Hello everyone! So, I am trying to work the OpenHardwareMonitorLib.dll with Unity to get some hardware stats displayed within Unity. I have added the plugin and it seems to be placed okay. I am getting some NullReferenceExceptions when I hit Play. Its because of the library for sure but I couldn't figure out exactly how to fix that. Could anyone please share their experiences with it? Any help would be really appreciated! The code I am using is as follows: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using OpenHardwareMonitor; using OpenHardwareMonitor.Hardware; using OpenHardwareMonitor.Collections; public class MenuManager : MonoBehaviour { // Start is called before the first frame update void Start() { GetSystemInfo(); } // Update is called once per frame void Update() { } public class UpdateVisitor : IVisitor { public void VisitComputer(IComputer computer) { computer.Traverse(this); } public void VisitHardware(IHardware hardware) { hardware.Update(); foreach (IHardware subHardware in hardware.SubHardware) subHardware.Accept(this); } public void VisitSensor(ISensor sensor) { } public void VisitParameter(IParameter parameter) { } } public static void GetSystemInfo() { UpdateVisitor updateVisitor = new UpdateVisitor(); Computer computer = new Computer(); computer.Open(); computer.CPUEnabled = true; computer.Accept(updateVisitor); for (int i = 0; i < computer.Hardware.Length; i++) { if (computer.Hardware[i].HardwareType == HardwareType.CPU) { for (int j = 0; j < computer.Hardware[i].Sensors.Length; j++) { if (computer.Hardware[i].Sensors[j].SensorType == SensorType.Temperature) Console.WriteLine(computer.Hardware[i].Sensors[j].Name + ":" + computer.Hardware[i].Sensors[j].Value.ToString() + "\r"); } } } computer.Close(); } } ![alt text][1] [1]: /storage/temp/177006-logohm.png

Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>