public static string GetAdapterMAC() { #if !UNITY_WEBPLAYER && !UNITY_ANDROID IPAddress localIP = CClientNetworkCtrl.GetLocalIP(); if (localIP != null) { NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); NetworkInterface[] array = allNetworkInterfaces; for (int i = 0; i < array.Length; i++) { NetworkInterface networkInterface = array[i]; IPInterfaceProperties iPProperties = networkInterface.GetIPProperties(); UnicastIPAddressInformationCollection unicastAddresses = iPProperties.UnicastAddresses; for (int j = 0; j < unicastAddresses.Count; j++) { if (unicastAddresses[j].Address.Equals(localIP)) { return(networkInterface.GetPhysicalAddress().ToString()); } } } } #endif return("000000000000"); }
public static List <string> GetAllMacAddress() { #if !UNITY_WEBPLAYER List <string> list = new List <string>(); IPAddress localIP = CClientNetworkCtrl.GetLocalIP(); if (localIP != null) { NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces(); NetworkInterface[] array = allNetworkInterfaces; for (int i = 0; i < array.Length; i++) { NetworkInterface networkInterface = array[i]; IPInterfaceProperties iPProperties = networkInterface.GetIPProperties(); UnicastIPAddressInformationCollection unicastAddresses = iPProperties.UnicastAddresses; for (int j = 0; j < unicastAddresses.Count; j++) { list.Add(networkInterface.GetPhysicalAddress().ToString()); } } } return(list); #else return(null); #endif }
public static string GetLocalIPString() { IPAddress localIP = CClientNetworkCtrl.GetLocalIP(); return((localIP == null) ? "127.0.0.1" : localIP.ToString()); }