1

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

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.

Any ideas?

Community
  • 1
  • 1
DreTaX
  • 760
  • 2
  • 9
  • 22
  • FYI, CPUID is not computer specific, all processors of the same model type all share the same CPUID. Unique id's in the CPUID stopped happening around the late 1990's with the pentium processor generation. – Scott Chamberlain Dec 17 '16 at 20:29
  • Then the BIOS ID would be more applicable. – DreTaX Dec 17 '16 at 20:30
  • Most BIOS's don't publish it and the ones that do have it disabled by default. Are you planning on making your game run on windows only? If so there are some simple options you can do. – Scott Chamberlain Dec 17 '16 at 20:31
  • Nah. It is running on linux too. – DreTaX Dec 17 '16 at 20:33

1 Answers1

2

Use SystemInfo.deviceUniqueIdentifier it is built in to unity. One thing to check however is it can return the value of SystemInfo.unsupportedIdentifier if it is running on a platform that does not provide a way to get a unique id.

using UnityEngine;

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

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.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • Well R.I.P. I'm on 4.5.5f1, and can't change since I'm haxing myself into game dlls. Thanks though that should be fine. Can people change that though? – DreTaX Dec 17 '16 at 21:02
  • `SystemInfo.unsupportedIdentifier` was not defined before `2017.4`, is there an equivalent string to test for in older Unity? – Jesse Chisholm Jul 25 '18 at 00:32
  • @JesseChisholm it is available, it is just if you change versions on the docs website it does not keep you on the page. Here is the 2008.1 version https://docs.unity3d.com/2018.1/Documentation/ScriptReference/SystemInfo-deviceUniqueIdentifier.html – Scott Chamberlain Jul 25 '18 at 01:19
  • @ScottChamberlain I didn't mean the in the documentation, I meant in code. When using Unity OLDER THAN 2017.4 (such as 5.6) is there some known value similar to `System.unsupportedIdentifier` that could be checked? or just hope that the `SystemInfo.deviceUniqueIdentifier` is empty if it is not supported? – Jesse Chisholm Jul 26 '18 at 20:42
  • @JesseChisholm `System.unsupportedIdentifier` [is available in 5.6](https://docs.unity3d.com/560/Documentation/ScriptReference/SystemInfo-unsupportedIdentifier.html). You don't need to know what the value is. Just do `if (SystemInfo.unsupportedIdentifier != SystemInfo.deviceUniqueIdentifier) { ... }` – Scott Chamberlain Jul 27 '18 at 00:38
  • @ScottChamberlain Thanks for mentioning that. It never occurred to me that a document page what said it was only available as far back as 2017.4 ( https://docs.unity3d.com/ScriptReference/SystemInfo-unsupportedIdentifier.html ) was also available in an unlinked legacy version ( https://docs.unity3d.com/560/Documentation/ScriptReference/SystemInfo-unsupportedIdentifier.html ) – Jesse Chisholm Jul 31 '18 at 20:21
  • I currently use WINAPI to build a better HWID system. I suggest you try to do that. Mine consists out of CPUID, BIOSID, BASEID, GPUID, and some other extra stuffs. – DreTaX Sep 09 '18 at 19:54
  • @DreTaX yes, but that only works on windows if your game is going to be cross platform you can't do it. – Scott Chamberlain Sep 09 '18 at 20:55