DreTaX
DreTaX

Reputation: 836

UnityEngine .NET 3.5 Get HardwareID without System.Management

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?

Upvotes: 1

Views: 1324

Answers (1)

Scott Chamberlain
Scott Chamberlain

Reputation: 127543

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.

Upvotes: 2

Related Questions