UnityEngine .NET 3.5 在没有 System.Management 的情况下获取 HardwareID [英] UnityEngine .NET 3.5 Get HardwareID without System.Management

查看:29
本文介绍了UnityEngine .NET 3.5 在没有 System.Management 的情况下获取 HardwareID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种使用此方法获取用户 HWID 的方法:如何在 C# 中快速获取硬件 ID?

I was looking for a way to get the user's HWID using this: How to fast get Hardware-ID in C#?

但是失败了.System.Management 未完全移植到 UnityEngine 4 上,我需要找到替代方法,至少可以访问 CPUID 或其他内容.

but failed. System.Management is not fully ported on UnityEngine 4 and I need to find an alternative, to atleast gain access to a CPUID or something.

有什么想法吗?

推荐答案

使用 SystemInfo.deviceUniqueIdentifier 它是内置的.但是要检查的一件事是,如果它在不提供获取唯一 ID 的方法的平台上运行,它可以返回 SystemInfo.unsupportedIdentifier 的值.

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour 
{
    void Start () {
        if (SystemInfo.unsupportedIdentifier != SystemInfo.deviceUniqueIdentifier)
        {
            // use SystemInfo.deviceUniqueIdentifier
        }   
    }
}

确保您运行的是 Unity 4.6.2 或更新版本 linux 上有一个错误,它没有返回一致的值,但它在 4.6.2 中得到修复.

Be sure you are running Unity 4.6.2 or newer as there was a bug for it on linux not returning consistent values but it was fixed in 4.6.2.

这篇关于UnityEngine .NET 3.5 在没有 System.Management 的情况下获取 HardwareID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆