unity 获取本机ip地址
IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName()); //Dns.GetHostName()获取本机名Dns.GetHostAddresses()根据本机名获取ip地址组
foreach (IPAddress ip in ips)
{
if (ip.AddressFamily == AddressFamily.InterNetwork)
{
ip4 = ip.ToString(); //ipv4
}
else if(ip.AddressFamily == AddressFamily.InterNetworkV6)
{
ipv6 = ip.ToString(); //ipv6
}
}