1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| using System.Net; using System.Net.Sockets;
public class GetIPAddress : MonoBehaviour { public string GetIP() { string ipAddress = ""; IPHostEntry host; host = Dns.GetHostEntry(Dns.GetHostName()); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { ipAddress = ip.ToString(); break; } } return ipAddress; } }
|