获取手机的mac地址
通过NetworkInterface.GetAllNetworkInterfaces()可以获取网络硬件信息的一些内容
using UnityEngine;
using System.Collections;
using System.Net.NetworkInformation;
public class Test : MonoBehaviour {
void Start() {
NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in nis) {
Debug.Log ("Name = " + ni.Name);
Debug.Log ("Des = " + ni.Description);
Debug.Log ("Type = " + ni.NetworkInterfaceType.ToString() );
Debug.Log ("Mac地址 = " + ni.GetPhysicalAddress().ToString() );
Debug.Log ("------------------------------------------------");
}
}
}
本文介绍了一种在Unity中获取设备MAC地址的方法,通过使用NetworkInterface.GetAllNetworkInterfaces()函数,可以遍历并打印出所有网络接口的相关信息,包括名称、描述、类型及MAC地址。

489

被折叠的 条评论
为什么被折叠?



