diff --git a/Lidgren.Network/Encryption/NetAESEncryption.cs b/Lidgren.Network/Encryption/NetAESEncryption.cs index 5ed5582..9ab9557 100644 --- a/Lidgren.Network/Encryption/NetAESEncryption.cs +++ b/Lidgren.Network/Encryption/NetAESEncryption.cs @@ -7,18 +7,30 @@ namespace Lidgren.Network public class NetAESEncryption : NetCryptoProviderBase { public NetAESEncryption(NetPeer peer) +#if UNITY + : base(peer, new RijndaelManaged()) +#else : base(peer, new AesCryptoServiceProvider()) +#endif { } public NetAESEncryption(NetPeer peer, string key) +#if UNITY + : base(peer, new RijndaelManaged()) +#else : base(peer, new AesCryptoServiceProvider()) +#endif { SetKey(key); } public NetAESEncryption(NetPeer peer, byte[] data, int offset, int count) +#if UNITY + : base(peer, new RijndaelManaged()) +#else : base(peer, new AesCryptoServiceProvider()) +#endif { SetKey(data, offset, count); } diff --git a/Lidgren.Network/NetBuffer.Write.cs b/Lidgren.Network/NetBuffer.Write.cs index 03e18ff..72f937c 100644 --- a/Lidgren.Network/NetBuffer.Write.cs +++ b/Lidgren.Network/NetBuffer.Write.cs @@ -101,6 +101,16 @@ namespace Lidgren.Network m_bitLength += 8; } + /// + /// Writes a byte at a given offset in the buffer + /// + public void WriteAt(Int32 offset, byte source) { + int newBitLength = Math.Max(m_bitLength, offset + 8); + EnsureBufferSize(newBitLength); + NetBitWriter.WriteByte((byte) source, 8, m_data, offset); + m_bitLength = newBitLength; + } + /// /// Writes a signed byte /// diff --git a/Lidgren.Network/Platform/PlatformConstrained.cs b/Lidgren.Network/Platform/PlatformConstrained.cs index 77ff6c5..3308bbf 100644 --- a/Lidgren.Network/Platform/PlatformConstrained.cs +++ b/Lidgren.Network/Platform/PlatformConstrained.cs @@ -1,4 +1,4 @@ -#if __CONSTRAINED__ || UNITY_STANDALONE_LINUX +#if __CONSTRAINED__ || UNITY_STANDALONE_LINUX || UNITY using System; using System.Collections.Generic; using System.Net; @@ -29,9 +29,9 @@ namespace Lidgren.Network public static IPAddress GetMyAddress(out IPAddress mask) { mask = null; -#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS try { +#if UNITY_ANDROID || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_IOS || UNITY if (!(UnityEngine.Application.internetReachability == UnityEngine.NetworkReachability.NotReachable)) { return null;