Comments (4)
To make this library work with android games made with Unity Engine, it needs to be compiled with the ANDROID symbol. When adding this symbol, the solution will "switch" to the android mode, requiring the Android namespace to access native structures (to get the IP address, I think). Now comes the problem:
To get the Android namespace I must add the Mono.Android (xamarin) reference, but this reference requires Mono 4.0 and Unity currently doesn't supports Mono 4.0, so I can't add the reference and consequently I can't build the library and can't use it.
I don't know if i'm making some mistake here, I'm not an expert, sorry.
from lidgren-network-gen3.
So, what exactly is wrong with this library?
from lidgren-network-gen3.
I can confirm it's working nicely on iOS with Unity 5.3.4. Note that you have to use the UNITY compile flag. I haven't tried Android yet, will report back soon.
EDIT: I can now confirm it's working on Android w/ mono/il2cpp backends.
from lidgren-network-gen3.
Friendly necropost for the wandering soul looking for help with this. There's a lot of good information scattered about several threads online, however few include encompassing instructions. If you're attempting to use Ligdren on Unity Android mobile, here are the steps you'll need to take. My setup for this process included Unity 2017.2.0f3 Personal and Visual Studio Community 2017. My target and minimum Android API levels in Unity are Android 7.1 'Noutgat' (API level 25) and Android 5.0 'Lollipop' (API level 21) respectively. Lidgren was successfully tested on a Google Pixel XL running Android 8.1.0.
You'll need to build your own dll for Unity with a few changes having been made. Here's how you'll go through the process of building a Unity android compatible dll.
- Download and open the latest version of Lidgren from the repo if you haven't already
- With the solution loaded, right click on References under the Lidgren.Network project in Visual Studio's Solution Explorer. Select 'Add Reference' and click 'Browse> Browse...'
- Navigate to Unity's managed dlls folder (C:\Program Files\Unity\Editor\Data\Managed) and add 'UnityEngine.dll'. This will make Unity's data types visible to Lidgren and should clear any undefined references in PlatformUnityExtras.cs if there were any.
- Expand the References explorer to ensure UnityEngine is present. Click on UnityEngine and in the 'UnityEngine Reference Properties' ensure that 'Copy Local' is set to true. This will place an extra copy of the UnityEngine dll in your output folder when you build.
- Press (Alt + Enter) or Right Click on the Lidgren.Network library in the Solution Explorer and select 'Properties'
- Under 'Application > Target framework', select 'Unity 3.5 .net Subset Base Class Libraries' from the drop down. In targeting .NET 3.5 the dll becomes actually usable by Unity
- Move to the 'Build' tab of the properties window and under 'General', include 'UNITY _CONSTRAINED_ ANDROID' in the Conditional compilation symbols. This will switch out which functionality gets compiled into the dll
- Save and compile the project
- Check your build folder (..\Lidgren.Network\bin\Debug...) for your Unity mobile ready Ligdren dll
- Copy all the contents of the build folder into a new folder within Unity's Asset folder,
you may chose to structure your directory to resemble something like (..\MyUnityProject\Assets\Plugins\Lidgren...) - Close and Reopen your Unity C# project in Visual Studio and look at the Solution Explorer. Make sure each of Visual Studio's projects includes Lidgren,Network as Unity should automatically have done.
- Include Lidgren.Network in your usings and you should be good to go! Deploy a small test demo to mobile and check that it works. I hope these instructions were applicable and easy to follow.
As a note, Unity will likely produce an error and question your placement of an extra UnityEngine.dll in the Assets folder. There are ways to tell Lidgren where to find the UnityEngine.dll, however this saves the most amount of time. Clear that error and it won't show up again.
Obviously, if you're building to Android, ensure that you've already gone through the process of setting up Unity Android support. There are plenty of tutorials online if you haven't already.
from lidgren-network-gen3.
Related Issues (20)
- Handshake Attempt Event
- Failed to send packet: System.Net.Sockets.SocketException HOT 2
- ReceivedPong doesn't consider late/not in order pong messages HOT 8
- Incorrect network messages/malformed packets could easily overwhelm the server HOT 2
- Cannot Reconnect
- Example Code from Basics doesn't yield same results HOT 1
- Trying to compile for Android HOT 2
- Accepting connection does not increase ConnectionsCount? HOT 1
- Is there a possibility to modify lidgren to support DTLS??
- [QUESTION] Thread safety HOT 5
- Unity 2019.4 LTS: calling client.Connect gives SocketException Invalid arguments immediately HOT 3
- Active forks? HOT 13
- Large unreliable message cannot be sent properly HOT 2
- Might want to lock stuff here? HOT 2
- The examples client gives error when trying to connect to server form second VS
- Unity network
- Is it possible to send and receive structs instead of classes ? HOT 1
- Is it still possible to build for Unity? HOT 3
- NetQueue concurrency HOT 2
- ICMP Destination unreachable (port unreachable) won't close connection HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lidgren-network-gen3.