Is it possible to pull the computers current IP address. I'm trying to figure out some code that will pull the computers IP Address and automatically place it in a text field before it starts a server. I'm only looking in JS because that's all I know. But help would be greatly appreciated.
Try this Code (csharp): import System.Net; function GetIP():String { var strHostName:String = ""; strHostName = System.Net.Dns.GetHostName(); var ipEntry:IPHostEntry = System.Net.Dns.GetHostEntry(strHostName); var addr:IPAddress[] = ipEntry.AddressList; return addr[addr.Length-1].ToString(); }
It works fine in the Unity development system but once compiled, it returns the hex number for the IPv6. I believe this is a hint towards fixing it: http://answers.unity3d.com/questions/39394/send-an-email-c-error.html But my Unityscript to C# is not strong enough to do the translation
Look at the code in the Multiplayer Network / Star Trooper tutorial. I did that just last week on the iPhone iTouch so I know it works.
The exact line is: var ipaddress = Network.player.ipAddress; on page 6 of http://download.unity3d.com/support/resources/files/MultiplayerTutorial.pdf
Sorry I was a bit too lazy to look it up myself and I figured the tutorial might be useful for other things to you.
Oh no problem. I appreciate it, A LOT. I put the info there for future people who happen across this (and also if that tutorial disappears for some reason or something)
I did the code above and I am NOT getting any IPv6 address. I wonder what I am missing. My OS has IPv6 connectivity and Unity just don't show anything. Could someone help me with IPv6 and Unity?
hi !!!!!!!! dns.gethostentry not working in uwp.. can you help me with that? im using unity 2017.4.2f2. Need to retrieve the local ip address from the hololens using c#.