2026-03-24 11:39:01 +08:00

34 lines
918 B
C#

using System.Collections;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using UnityEngine;
public class PcId : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
GetMachineGuid();
Debug.Log("---------- "+ Hostid);
}
public string Hostid = "";
public string GetMachineGuid()
{
if (string.IsNullOrEmpty(Hostid))
{
NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in nis)
{
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 ||
ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
Hostid = ni.GetPhysicalAddress().ToString();
break;
}
}
}
return Hostid;
}
}