From 9b82d2a0c6ee60d521a634601d461914086b3311 Mon Sep 17 00:00:00 2001 From: Michael Lidgren Date: Tue, 5 May 2015 15:41:46 +0200 Subject: [PATCH] UNITY specifics for GetMyAddress incorporated --- Lidgren.Network/Platform/PlatformConstrained.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lidgren.Network/Platform/PlatformConstrained.cs b/Lidgren.Network/Platform/PlatformConstrained.cs index 0ffe874..450415d 100644 --- a/Lidgren.Network/Platform/PlatformConstrained.cs +++ b/Lidgren.Network/Platform/PlatformConstrained.cs @@ -28,6 +28,18 @@ namespace Lidgren.Network /// public static IPAddress GetMyAddress(out IPAddress mask) { +#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDLONE_WIN || UNITY_STANDLONE_LINX || UNITY_IOS + try + { + if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable)) + return null; + return IPAddress.Parse(UnityEngine.Network.player.externalIP); + } + catch // Catch Access Denied errors + { + return null; + } +#endif mask = null; return null; }