//获取ip地址
public static string GetIPAddress()
{
string ip = NetWork.player.ipAddress;
if(ip == null || ip == "")
{
try
{
string hostName = System.Net.Dns.GetHostName();
if(hostName != null)
{
System.Net.IPAddress[] ips = System.Net.Dns.GetHostAddresses(hostName);
if(ips.Length > 0)
{
ip = ips[0].ToString();
}
}
else
{
ip = "";
}
}
catch(Exception e)
{
ip = "";
}
}
return ip;
}
unity获取手机联网ip
最新推荐文章于 2024-07-29 18:02:37 发布
