【问题标题】:UnityEngine .NET 3.5 Get HardwareID without System.ManagementUnityEngine .NET 3.5 在没有 System.Management 的情况下获取 HardwareID
【发布时间】:2016-12-18 04:49:39
【问题描述】:

我正在寻找一种方法来获取用户的 HWID:How to fast get Hardware-ID in C#?

但是失败了。 System.Management 没有完全移植到 UnityEngine 4 上,我需要找到一个替代方案,以至少获得对 CPUID 或其他东西的访问权限。

有什么想法吗?

【问题讨论】:

  • 仅供参考,CPUID 不是特定于计算机的,相同型号类型的所有处理器都共享相同的 CPUID。 CPUID 中的唯一 ID 在 1990 年代后期随着奔腾处理器一代停止出现。
  • 那么BIOS ID会更适用。
  • 大多数 BIOS 不发布它,并且默认情况下禁用它。你打算让你的游戏只在 Windows 上运行吗?如果是这样,您可以做一些简单的选择。
  • 不。它也在linux上运行。

标签: c# unity3d


【解决方案1】:

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

using UnityEngine;

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

确保您以 there was a bug for it on linux not returning consistent values 运行 Unity 4.6.2 或更新版本,但它已在 4.6.2 中修复。

【讨论】:

  • 安息吧。我在 4.5.5f1 上,并且无法更改,因为我正在将自己陷入游戏 dll 中。谢谢,虽然那应该没问题。人们可以改变它吗?
  • SystemInfo.unsupportedIdentifier 没有在 2017.4 之前定义,在旧版 Unity 中是否有等效的字符串可以测试?
  • @JesseChisholm 它可用,只是如果您在文档网站上更改版本,它不会让您留在页面上。这里是2008.1版本docs.unity3d.com/2018.1/Documentation/ScriptReference/…
  • @ScottChamberlain 我不是指文档中的,我指的是代码中的。使用 Unity OLDER THAN 2017.4(例如 5.6)时,是否有一些类似于 System.unsupportedIdentifier 的已知值可以检查?或者只是希望SystemInfo.deviceUniqueIdentifier 不受支持时为空?
  • @JesseChisholm System.unsupportedIdentifier is available in 5.6。你不需要知道价值是什么。就做if (SystemInfo.unsupportedIdentifier != SystemInfo.deviceUniqueIdentifier) { ... }
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-19
  • 1970-01-01
  • 2019-10-14
  • 2013-10-10
  • 2012-06-01
  • 2020-04-13
相关资源
最近更新 更多