1
0
mirror of https://github.com/lidgren/lidgren-network-gen3.git synced 2026-05-18 16:16:35 +09:00

Unity Support. Just compile with __CONSTRAINED__ and UNITY keyworkds and add a reference to UnityEngine.dll

This commit is contained in:
Andrés Leone
2015-12-13 03:42:39 +01:00
parent 6dac4d7457
commit 208f129e3f
2 changed files with 14 additions and 2 deletions

View File

@@ -7,18 +7,30 @@ namespace Lidgren.Network
public class NetAESEncryption : NetCryptoProviderBase public class NetAESEncryption : NetCryptoProviderBase
{ {
public NetAESEncryption(NetPeer peer) public NetAESEncryption(NetPeer peer)
#if UNITY
: base(peer, new RijndaelManaged())
#else
: base(peer, new AesCryptoServiceProvider()) : base(peer, new AesCryptoServiceProvider())
#endif
{ {
} }
public NetAESEncryption(NetPeer peer, string key) public NetAESEncryption(NetPeer peer, string key)
#if UNITY
: base(peer, new RijndaelManaged())
#else
: base(peer, new AesCryptoServiceProvider()) : base(peer, new AesCryptoServiceProvider())
#endif
{ {
SetKey(key); SetKey(key);
} }
public NetAESEncryption(NetPeer peer, byte[] data, int offset, int count) public NetAESEncryption(NetPeer peer, byte[] data, int offset, int count)
#if UNITY
: base(peer, new RijndaelManaged())
#else
: base(peer, new AesCryptoServiceProvider()) : base(peer, new AesCryptoServiceProvider())
#endif
{ {
SetKey(data, offset, count); SetKey(data, offset, count);
} }

View File

@@ -1,4 +1,4 @@
#if __CONSTRAINED__ || UNITY_STANDALONE_LINUX #if __CONSTRAINED__ || UNITY_STANDALONE_LINUX || UNITY
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
@@ -29,9 +29,9 @@ namespace Lidgren.Network
public static IPAddress GetMyAddress(out IPAddress mask) public static IPAddress GetMyAddress(out IPAddress mask)
{ {
mask = null; mask = null;
#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS
try try
{ {
#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS || UNITY
if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable)) if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable))
{ {
return null; return null;