I am using “WMI C#” To try to display my computer Processor information onto a UI in unity. But I can not figure out why this will not work, I have tried adding System.Management as a reference as well that did not work, I also tried using “PerformanceCounter” but could not get that to work at all as well, Maybe the code does not work for unity, no clue still learning code so maybe I am over looking something so I figured I would ask on here and maybe someone can point me in the right direction with this project
thanks in advance. here is the code I am currently trying to get to work.
using UnityEngine;
using System;
using System.Management;
namespace SystemInformation
{
public class USAGE
{
static void Main(string[] args)
{
GetComponent("Win32_Processor", "LoadPercentage");
}
private static void GetComponent(string hwclass, string syntax)
{
ManagementObjectSearcher mos = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM " + hwclass);
foreach (ManagementObject mj in mos.Get())
{
UnityEngine.Debug.Log(Convert.ToString(mj[syntax]));
}
}
}
}