Browse Source

Patch ENet.cs; fixes "enet module not found" when using it with Ignorance

Matt Coburn 6 years ago
parent
commit
5ca9cd549c
1 changed files with 14 additions and 7 deletions
  1. 14 7
      Source/Managed/ENet.cs

+ 14 - 7
Source/Managed/ENet.cs

@@ -910,13 +910,20 @@ namespace ENet {
 
 	[SuppressUnmanagedCodeSecurity]
 	internal static class Native {
-		#if __IOS__ || UNITY_IOS && !UNITY_EDITOR
-			private const string nativeLibrary = "__Internal";
-		#else
-			private const string nativeLibrary = "enet";
-		#endif
-
-		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+#if __IOS__ || UNITY_IOS && !UNITY_EDITOR
+        // iOS
+		private const string nativeLibrary = "__Internal";
+#elif __APPLE__ || UNITY_STANDALONE_OSX && !UNITY_EDITOR
+        // MacOS
+        // Custom ENet Repo builds as libenet.bundle; make sure it's the same.
+        private const string nativeLibrary = "libenet";
+#else
+        // Assume everything else, Windows et al...
+        // This might be interesting if someone's building for Nintendo Switch or whatnot...
+        private const string nativeLibrary = "enet";
+#endif
+
+        [DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern int enet_initialize();
 
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]