Unity 获取设备的MAC等硬件信息

print(SystemInfo.graphicsDeviceID);//获取显卡的唯一标识符
print(SystemInfo.deviceUniqueIdentifier);//获取设备唯一标识符
print(SystemInfo.deviceType);//获取设备的类型
print(SystemInfo.processorType);//获取处理器的类型

using System.Net.NetworkInformation;


    private void CheckIdVerify()
    {
        var gpuTpye = SystemInfo.graphicsDeviceType;
        var gpuId = SystemInfo.graphicsDeviceID;
        var macId = GetmacAddress();
        Debug.Log(gpuTpye+ ": "+gpuId+",macId= "+macId);
    }


    public static string GetmacAddress()
    {
        string strphysicalAddress = "";
        var interfaces = NetworkInterface.GetAllNetworkInterfaces();
        foreach (var iface in interfaces)
        {
            if (iface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 && 
                iface.OperationalStatus == OperationalStatus.Up)
            {
                var physicalAddress = iface.GetPhysicalAddress();
                var macAddress = physicalAddress.ToString();
                Debug.Log("Current MAC address: " + macAddress);
                strphysicalAddress = macAddress;
                break;
            }
            else
            {
                var physicalAddress = iface.GetPhysicalAddress();
                var macAddress = physicalAddress.ToString();
                Debug.Log("没网的 MAC address: " + macAddress);
            }
        }
       
        return strphysicalAddress;
    }

注意: 设备ID慎用,据说在Android中受签名影响会变。

[Unity3D]获取设备唯一标识符_unity获取设备唯一设备码_iningwei的博客-CSDN博客

猜你喜欢

转载自blog.csdn.net/qq_42672770/article/details/131327323
今日推荐