Просмотр исходного кода

IOS il2cpp p/invoke调用有很多bug,必须修改代码绕过去,增加了安卓和ios使用的enet库,安卓和ios都测试通过,方便大家使用

tanghai 8 лет назад
Родитель
Сommit
c0e990328b

+ 2 - 0
README

@@ -1,3 +1,5 @@
+2017-4-17: IOS il2cpp p/invoke调用有很多bug,必须修改代码绕过去,增加了安卓和ios使用的enet库,安卓和ios都测试通过,方便大家使用
+
 2017-3-30: unity升级到5.5.2,增加vs调试启动参数,很多人问我,所以加上去了。增加主线程同步上下文,mongodb异步函数就能回调到主线程
 
 2017-2-17: 使用ILRuntime提供Unity C#代码热更新支持,并且抹平了Mono层和ILRuntime层差异,使用起来风格与原来用法保持一致, 扔掉你的lua代码吧!

+ 9 - 0
Unity/Assets/Plugins/Android/libs.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 49d28ac61423dfd40b611f2a3782a5b4
+folderAsset: yes
+timeCreated: 1492410564
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Unity/Assets/Plugins/Android/libs/armeabi-v7a.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: d3583ad876126244c805422fc8291629
+folderAsset: yes
+timeCreated: 1490670825
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Plugins/Android/libs/armeabi-v7a/libENet.so


+ 25 - 0
Unity/Assets/Plugins/Android/libs/armeabi-v7a/libENet.so.meta

@@ -0,0 +1,25 @@
+fileFormatVersion: 2
+guid: f348e42d420b0cf4bb775e1e179105f7
+timeCreated: 1490670825
+licenseType: Pro
+PluginImporter:
+  serializedVersion: 1
+  iconMap: {}
+  executionOrder: {}
+  isPreloaded: 0
+  isOverridable: 0
+  platformData:
+    Android:
+      enabled: 1
+      settings:
+        CPU: ARMv7
+    Any:
+      enabled: 0
+      settings: {}
+    Editor:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Unity/Assets/Plugins/Android/libs/armeabi.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: e40b340040b804c1dacad73cf46c9e54
+folderAsset: yes
+timeCreated: 1482825912
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 9 - 0
Unity/Assets/Plugins/Android/libs/x86.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 7c9afaf16b7d683469ddc341d3090579
+folderAsset: yes
+timeCreated: 1490671742
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Plugins/Android/libs/x86/libENet.so


+ 69 - 0
Unity/Assets/Plugins/Android/libs/x86/libENet.so.meta

@@ -0,0 +1,69 @@
+fileFormatVersion: 2
+guid: 931d8a0816d6cc649863909d8dbd4d4c
+timeCreated: 1490670825
+licenseType: Pro
+PluginImporter:
+  serializedVersion: 1
+  iconMap: {}
+  executionOrder: {}
+  isPreloaded: 0
+  isOverridable: 0
+  platformData:
+    Android:
+      enabled: 1
+      settings:
+        CPU: x86
+    Any:
+      enabled: 0
+      settings:
+        Exclude Android: 0
+        Exclude Editor: 1
+        Exclude Linux: 1
+        Exclude Linux64: 1
+        Exclude LinuxUniversal: 1
+        Exclude OSXIntel: 1
+        Exclude OSXIntel64: 1
+        Exclude OSXUniversal: 1
+        Exclude Win: 1
+        Exclude Win64: 1
+    Editor:
+      enabled: 0
+      settings:
+        CPU: x86
+        DefaultValueInitialized: true
+        OS: AnyOS
+    Linux:
+      enabled: 0
+      settings:
+        CPU: x86
+    Linux64:
+      enabled: 0
+      settings:
+        CPU: None
+    LinuxUniversal:
+      enabled: 0
+      settings:
+        CPU: None
+    OSXIntel:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+    OSXIntel64:
+      enabled: 0
+      settings:
+        CPU: None
+    OSXUniversal:
+      enabled: 0
+      settings:
+        CPU: None
+    Win:
+      enabled: 0
+      settings:
+        CPU: AnyCPU
+    Win64:
+      enabled: 0
+      settings:
+        CPU: None
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 4 - 4
Unity/Assets/Plugins/Base/Network/UNet/Library.cs

@@ -6,7 +6,7 @@ namespace Base
 	{
 		public static void Initialize()
 		{
-			int ret = NativeMethods.ENetInitialize();
+			int ret = NativeMethods.enet_initialize();
 			if (ret < 0)
 			{
 				throw new Exception($"Initialization failed, ret: {ret}");
@@ -15,18 +15,18 @@ namespace Base
 
 		public static void Deinitialize()
 		{
-			NativeMethods.ENetDeinitialize();
+			NativeMethods.enet_deinitialize();
 		}
 
 		public static uint Time
 		{
 			get
 			{
-				return NativeMethods.ENetTimeGet();
+				return NativeMethods.enet_time_get();
 			}
 			set
 			{
-				NativeMethods.ENetTimeSet(value);
+				NativeMethods.enet_time_set(value);
 			}
 		}
 	}

+ 64 - 60
Unity/Assets/Plugins/Base/Network/UNet/NativeMethods.cs

@@ -6,100 +6,104 @@ namespace Base
 {
 	public static class NativeMethods
 	{
+#if UNITY_IOS && !UNITY_EDITOR
+		private const string LIB = "__Internal";
+#else
 		private const string LIB = "ENet";
+#endif
 
 		public const int ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255;
 		public const int ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xfff;
 
-		[DllImport(LIB, EntryPoint = "enet_address_set_host", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetAddressSetHost(ref ENetAddress address, string hostName);
+		[DllImport(LIB)]
+		internal static extern int enet_address_set_host(ref ENetAddress address, string hostName);
 
-		[DllImport(LIB, EntryPoint = "enet_address_get_host", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetAddressGetHost(ref ENetAddress address, StringBuilder hostName, uint nameLength);
+		[DllImport(LIB)]
+		internal static extern int enet_address_get_host(ref ENetAddress address, StringBuilder hostName, uint nameLength);
 
-		[DllImport(LIB, EntryPoint = "enet_address_get_host_ip", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetAddressGetHostIp(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
+		[DllImport(LIB)]
+		internal static extern int enet_address_get_host_ip(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
 
-		[DllImport(LIB, EntryPoint = "enet_deinitialize", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetDeinitialize();
+		[DllImport(LIB)]
+		internal static extern void enet_deinitialize();
 
-		[DllImport(LIB, EntryPoint = "enet_initialize", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetInitialize();
+		[DllImport(LIB)]
+		internal static extern int enet_initialize();
 
-		[DllImport(LIB, EntryPoint = "enet_host_create", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern IntPtr ENetHostCreate(
+		[DllImport(LIB)]
+		internal static extern IntPtr enet_host_create(
 				ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
 
-		[DllImport(LIB, EntryPoint = "enet_host_create", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern IntPtr ENetHostCreate(IntPtr address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
+		[DllImport(LIB)]
+		internal static extern IntPtr enet_host_create(IntPtr address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
 
-		[DllImport(LIB, EntryPoint = "enet_host_destroy", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostDestroy(IntPtr host);
+		[DllImport(LIB)]
+		internal static extern void enet_host_destroy(IntPtr host);
 
-		[DllImport(LIB, EntryPoint = "enet_host_connect", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern IntPtr ENetHostConnect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
+		[DllImport(LIB)]
+		internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
 
-		[DllImport(LIB, EntryPoint = "enet_host_broadcast", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostBroadcast(IntPtr host, byte channelID, IntPtr packet);
+		[DllImport(LIB)]
+		internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
 
-		[DllImport(LIB, EntryPoint = "enet_host_compress", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostCompress(IntPtr host, IntPtr compressor);
+		[DllImport(LIB)]
+		internal static extern void enet_host_compress(IntPtr host, IntPtr compressor);
 
-		[DllImport(LIB, EntryPoint = "enet_host_compress_with_range_coder", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetHostCompressWithRangeCoder(IntPtr host);
+		[DllImport(LIB)]
+		internal static extern int enet_host_compress_with_range_coder(IntPtr host);
 
-		[DllImport(LIB, EntryPoint = "enet_host_channel_limit", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostChannelLimit(IntPtr host, uint channelLimit);
+		[DllImport(LIB)]
+		internal static extern void enet_host_channel_limit(IntPtr host, uint channelLimit);
 
-		[DllImport(LIB, EntryPoint = "enet_host_bandwidth_limit", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostBandwidthLimit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
+		[DllImport(LIB)]
+		internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
 
-		[DllImport(LIB, EntryPoint = "enet_host_flush", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetHostFlush(IntPtr host);
+		[DllImport(LIB)]
+		internal static extern void enet_host_flush(IntPtr host);
 
-		[DllImport(LIB, EntryPoint = "enet_host_check_events", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetHostCheckEvents(IntPtr host, ENetEvent ev);
+		[DllImport(LIB)]
+		internal static extern int enet_host_check_events(IntPtr host, ref ENetEvent ev);
 
-		[DllImport(LIB, EntryPoint = "enet_host_service", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetHostService(IntPtr host, ENetEvent ev, uint timeout);
+		[DllImport(LIB)]
+		internal static extern int enet_host_service(IntPtr host, IntPtr ev, uint timeout);
 
-		[DllImport(LIB, EntryPoint = "enet_time_get", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern uint ENetTimeGet();
+		[DllImport(LIB)]
+		internal static extern uint enet_time_get();
 
-		[DllImport(LIB, EntryPoint = "enet_time_set", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetTimeSet(uint newTimeBase);
+		[DllImport(LIB)]
+		internal static extern void enet_time_set(uint newTimeBase);
 
-		[DllImport(LIB, EntryPoint = "enet_packet_create", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern IntPtr ENetPacketCreate(byte[] data, uint dataLength, PacketFlags flags);
+		[DllImport(LIB)]
+		internal static extern IntPtr enet_packet_create(byte[] data, uint dataLength, PacketFlags flags);
 
-		[DllImport(LIB, EntryPoint = "enet_packet_destroy", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPacketDestroy(IntPtr packet);
+		[DllImport(LIB)]
+		internal static extern void enet_packet_destroy(IntPtr packet);
 
-		[DllImport(LIB, EntryPoint = "enet_packet_resize", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetPacketResize(IntPtr packet, uint dataLength);
+		[DllImport(LIB)]
+		internal static extern int enet_packet_resize(IntPtr packet, uint dataLength);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_throttle_configure", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerThrottleConfigure(IntPtr peer, uint interval, uint acceleration, uint deceleration);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_throttle_configure(IntPtr peer, uint interval, uint acceleration, uint deceleration);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_send", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern int ENetPeerSend(IntPtr peer, byte channelID, IntPtr packet);
+		[DllImport(LIB)]
+		internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_receive", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern IntPtr ENetPeerReceive(IntPtr peer, out byte channelID);
+		[DllImport(LIB)]
+		internal static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_reset", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerReset(IntPtr peer);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_reset(IntPtr peer);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_ping", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerPing(IntPtr peer);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_ping(IntPtr peer);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_disconnect_now", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerDisconnectNow(IntPtr peer, uint data);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_disconnect", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerDisconnect(IntPtr peer, uint data);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_disconnect(IntPtr peer, uint data);
 
-		[DllImport(LIB, EntryPoint = "enet_peer_disconnect_later", CallingConvention = CallingConvention.Cdecl)]
-		internal static extern void ENetPeerDisconnectLater(IntPtr peer, uint data);
+		[DllImport(LIB)]
+		internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
 	}
 }

+ 1 - 1
Unity/Assets/Plugins/Base/Network/UNet/NativeStructs.cs

@@ -35,7 +35,7 @@ namespace Base
 
 	// ENetEvent
 	[StructLayout(LayoutKind.Sequential)]
-	internal class ENetEvent
+	internal struct ENetEvent
 	{
 		public EventType Type;
 		public IntPtr Peer;

+ 2 - 2
Unity/Assets/Plugins/Base/Network/UNet/UPacket.cs

@@ -16,7 +16,7 @@ namespace Base
 			{
 				throw new ArgumentNullException(nameof(data));
 			}
-			this.PacketPtr = NativeMethods.ENetPacketCreate(data, (uint) data.Length, flags);
+			this.PacketPtr = NativeMethods.enet_packet_create(data, (uint) data.Length, flags);
 			if (this.PacketPtr == IntPtr.Zero)
 			{
 				throw new Exception("Packet creation call failed");
@@ -40,7 +40,7 @@ namespace Base
 				return;
 			}
 
-			NativeMethods.ENetPacketDestroy(this.PacketPtr);
+			NativeMethods.enet_packet_destroy(this.PacketPtr);
 			this.PacketPtr = IntPtr.Zero;
 		}
 

+ 35 - 45
Unity/Assets/Plugins/Base/Network/UNet/UPoller.cs

@@ -12,7 +12,7 @@ namespace Base
 		}
 
 		public USocketManager USocketManager { get; }
-		private readonly QueueDictionary<IntPtr, ENetEvent> connQueue = new QueueDictionary<IntPtr, ENetEvent>();
+		private readonly Queue<IntPtr> connQueue = new Queue<IntPtr>();
 
 		private IntPtr host;
 
@@ -27,33 +27,40 @@ namespace Base
 
 		public UPoller(string hostName, ushort port)
 		{
-			this.USocketManager = new USocketManager();
-			
-			UAddress address = new UAddress(hostName, port);
-			ENetAddress nativeAddress = address.Struct;
-			this.host = NativeMethods.ENetHostCreate(ref nativeAddress,
-					NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
+			try
+			{
+				this.USocketManager = new USocketManager();
 
-			if (this.host == IntPtr.Zero)
+				UAddress address = new UAddress(hostName, port);
+				ENetAddress nativeAddress = address.Struct;
+				this.host = NativeMethods.enet_host_create(ref nativeAddress,
+						NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
+
+				if (this.host == IntPtr.Zero)
+				{
+					throw new Exception("Host creation call failed.");
+				}
+
+				NativeMethods.enet_host_compress_with_range_coder(this.host);
+			}
+			catch (Exception e)
 			{
-				throw new Exception("Host creation call failed.");
+				throw new Exception($"UPoll construct error, address: {hostName}:{port}", e);
 			}
-
-			NativeMethods.ENetHostCompressWithRangeCoder(this.host);
 		}
 
 		public UPoller()
 		{
 			this.USocketManager = new USocketManager();
 
-			this.host = NativeMethods.ENetHostCreate(IntPtr.Zero, NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
+			this.host = NativeMethods.enet_host_create(IntPtr.Zero, NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, 0, 0, 0);
 
 			if (this.host == IntPtr.Zero)
 			{
 				throw new Exception("Host creation call failed.");
 			}
 
-			NativeMethods.ENetHostCompressWithRangeCoder(this.host);
+			NativeMethods.enet_host_compress_with_range_coder(this.host);
 		}
 
 		public void Dispose()
@@ -63,7 +70,7 @@ namespace Base
 				return;
 			}
 
-			NativeMethods.ENetHostDestroy(this.host);
+			NativeMethods.enet_host_destroy(this.host);
 
 			this.host = IntPtr.Zero;
 		}
@@ -76,24 +83,9 @@ namespace Base
 			}
 		}
 
-		private ENetEvent TryGetEvent()
-		{
-			if (this.eNetEventCache == null)
-			{
-				this.eNetEventCache = new ENetEvent();
-			}
-			if (NativeMethods.ENetHostCheckEvents(this.host, this.eNetEventCache) <= 0)
-			{
-				return null;
-			}
-			ENetEvent eNetEvent = this.eNetEventCache;
-			this.eNetEventCache = null;
-			return eNetEvent;
-		}
-
 		public void Flush()
 		{
-			NativeMethods.ENetHostFlush(this.host);
+			NativeMethods.enet_host_flush(this.host);
 		}
 
 		public void Add(Action action)
@@ -116,8 +108,7 @@ namespace Base
 			// 如果有请求连接缓存的包,从缓存中取
 			if (this.connQueue.Count > 0)
 			{
-				IntPtr ptr = this.connQueue.FirstKey;
-				this.connQueue.Remove(ptr);
+				IntPtr ptr = this.connQueue.Dequeue();
 
 				USocket socket = new USocket(ptr, this);
 				this.USocketManager.Add(ptr, socket);
@@ -136,7 +127,7 @@ namespace Base
 			{
 				this.AcceptTcs.TrySetException(new Exception("socket disconnected in accpet"));
 			}
-			
+
 			USocket socket = new USocket(eEvent.Peer, this);
 			this.USocketManager.Add(socket.PeerPtr, socket);
 			socket.OnAccepted();
@@ -163,7 +154,7 @@ namespace Base
 
 		private int Service()
 		{
-			int ret = NativeMethods.ENetHostService(this.host, null, 0);
+			int ret = NativeMethods.enet_host_service(this.host, IntPtr.Zero, 0);
 			return ret;
 		}
 
@@ -178,20 +169,19 @@ namespace Base
 
 			while (true)
 			{
-				ENetEvent eNetEvent = this.TryGetEvent();
-				if (eNetEvent == null)
+				if (NativeMethods.enet_host_check_events(this.host, ref this.eNetEventCache) <= 0)
 				{
 					return;
 				}
 
-				switch (eNetEvent.Type)
+				switch (this.eNetEventCache.Type)
 				{
 					case EventType.Connect:
 						{
 							// 这是一个connect peer
-							if (this.USocketManager.ContainsKey(eNetEvent.Peer))
+							if (this.USocketManager.ContainsKey(this.eNetEventCache.Peer))
 							{
-								USocket uSocket = this.USocketManager[eNetEvent.Peer];
+								USocket uSocket = this.USocketManager[this.eNetEventCache.Peer];
 								uSocket.OnConnected();
 								break;
 							}
@@ -199,26 +189,26 @@ namespace Base
 							// 这是accept peer
 							if (this.AcceptTcs != null)
 							{
-								this.OnAccepted(eNetEvent);
+								this.OnAccepted(this.eNetEventCache);
 								break;
 							}
 
 							// 如果server端没有acceptasync,则请求放入队列
-							this.connQueue.Add(eNetEvent.Peer, eNetEvent);
+							this.connQueue.Enqueue(this.eNetEventCache.Peer);
 							break;
 						}
 					case EventType.Receive:
 						{
-							USocket uSocket = this.USocketManager[eNetEvent.Peer];
-							uSocket.OnReceived(eNetEvent);
+							USocket uSocket = this.USocketManager[this.eNetEventCache.Peer];
+							uSocket.OnReceived(this.eNetEventCache);
 							break;
 						}
 					case EventType.Disconnect:
 						{
-							USocket uSocket = this.USocketManager[eNetEvent.Peer];
+							USocket uSocket = this.USocketManager[this.eNetEventCache.Peer];
 							this.USocketManager.Remove(uSocket.PeerPtr);
 							uSocket.PeerPtr = IntPtr.Zero;
-							uSocket.OnDisconnect(eNetEvent);
+							uSocket.OnDisconnect(this.eNetEventCache);
 							break;
 						}
 				}

+ 3 - 3
Unity/Assets/Plugins/Base/Network/UNet/USocket.cs

@@ -65,7 +65,7 @@ namespace Base
 			}
 
 			poller.USocketManager.Remove(this.PeerPtr);
-			NativeMethods.ENetPeerDisconnectNow(this.PeerPtr, 0);
+			NativeMethods.enet_peer_disconnect_now(this.PeerPtr, 0);
 			this.PeerPtr = IntPtr.Zero;
 		}
 
@@ -109,7 +109,7 @@ namespace Base
 			UAddress address = new UAddress(host, port);
 			ENetAddress nativeAddress = address.Struct;
 
-			this.PeerPtr = NativeMethods.ENetHostConnect(this.poller.Host, ref nativeAddress, 2, 0);
+			this.PeerPtr = NativeMethods.enet_host_connect(this.poller.Host, ref nativeAddress, 2, 0);
 			if (this.PeerPtr == IntPtr.Zero)
 			{
 				throw new Exception($"host connect call failed, {host}:{port}");
@@ -129,7 +129,7 @@ namespace Base
 				return;
 			}
 			UPacket packet = new UPacket(data, flags);
-			NativeMethods.ENetPeerSend(this.PeerPtr, channelID, packet.PacketPtr);
+			NativeMethods.enet_peer_send(this.PeerPtr, channelID, packet.PacketPtr);
 			// enet_peer_send函数会自动删除packet,设置为0,防止Dispose或者析构函数再次删除
 			packet.PacketPtr = IntPtr.Zero;
 		}

BIN
Unity/Assets/Plugins/iOS/libENet.a


+ 24 - 0
Unity/Assets/Plugins/iOS/libENet.a.meta

@@ -0,0 +1,24 @@
+fileFormatVersion: 2
+guid: b45e030b68c365a47a02ac6d9b7e2061
+timeCreated: 1491907059
+licenseType: Pro
+PluginImporter:
+  serializedVersion: 1
+  iconMap: {}
+  executionOrder: {}
+  isPreloaded: 0
+  isOverridable: 0
+  platformData:
+    Any:
+      enabled: 0
+      settings: {}
+    Editor:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+    iOS:
+      enabled: 1
+      settings: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Unity/Assets/Res/Code/Hotfix.dll.bytes


BIN
Unity/Assets/Res/Code/Hotfix.dll.mdb.bytes


BIN
Unity/Assets/Res/Code/Hotfix.pdb.bytes


+ 9 - 0
Unity/Unity.Editor.csproj

@@ -110,12 +110,21 @@
     <Reference Include="UnityEditor.Android.Extensions">
       <HintPath>Library\UnityAssemblies\UnityEditor.Android.Extensions.dll</HintPath>
     </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.dll</HintPath>
+    </Reference>
     <Reference Include="UnityEditor.WindowsStandalone.Extensions">
       <HintPath>Library\UnityAssemblies\UnityEditor.WindowsStandalone.Extensions.dll</HintPath>
     </Reference>
     <Reference Include="SyntaxTree.VisualStudio.Unity.Bridge">
       <HintPath>Library\UnityAssemblies\SyntaxTree.VisualStudio.Unity.Bridge.dll</HintPath>
     </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Xcode">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Common">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll</HintPath>
+    </Reference>
     <Reference Include="AsyncBridge.Net35">
       <HintPath>Assets\CSharp vNext Support\AsyncTools\Plugins\AsyncBridge.Net35.dll</HintPath>
     </Reference>

+ 6 - 0
Unity/Unity.Plugins.csproj

@@ -74,6 +74,12 @@
     <Reference Include="UnityEditor">
       <HintPath>Library\UnityAssemblies\UnityEditor.dll</HintPath>
     </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Xcode">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Common">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll</HintPath>
+    </Reference>
     <Reference Include="AsyncBridge.Net35">
       <HintPath>Assets\CSharp vNext Support\AsyncTools\Plugins\AsyncBridge.Net35.dll</HintPath>
     </Reference>

+ 6 - 0
Unity/Unity.csproj

@@ -74,6 +74,12 @@
     <Reference Include="UnityEditor">
       <HintPath>Library\UnityAssemblies\UnityEditor.dll</HintPath>
     </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Xcode">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll</HintPath>
+    </Reference>
+    <Reference Include="UnityEditor.iOS.Extensions.Common">
+      <HintPath>Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll</HintPath>
+    </Reference>
     <Reference Include="AsyncBridge.Net35">
       <HintPath>Assets\CSharp vNext Support\AsyncTools\Plugins\AsyncBridge.Net35.dll</HintPath>
     </Reference>