using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Net; using UnityEngine; using UnityEngine.Networking.Types; using Valve.Newtonsoft.Json.Utilities; public class IpAddressDisplay : MonoBehaviour { private string ipAddress; private void OnGUI() { GUI.TextField(new Rect(Screen.width - 130f, Screen.height - 30f, 120f, 20f), ipAddress); } void Start() { string usedIp = null; foreach (var ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { if (usedIp == null || ip.ToString().StartsWith("192.168.1.")) { usedIp = ip.ToString(); } } } ipAddress = usedIp; } }