ENet Unity Mobile Setup
Bootstrap setup for a client server architecture
Description
A multiplayer setup with a unity client and a .Net Core server. The application is a very simple chat server, that shows how the clients can communicate with the server and vice versa. Other than being a small tech demo, the repo explains how to compile ENet for android and iOS and provides built libraries for those platforms to kickstart your project.
Client platform support | 32 Bit | 64 bit |
---|---|---|
Android | ✔️ | ✔️ |
iOS | ➖ | ✔️ |
Windows | ❌ | ✔️ |
Mac | ❌ | ✔️ |
Linux | ❌ | ✔️ |
The server application is built with .Net Core and therefore will run on Windows, Mac or Linux.
Libraries
- ENet-CSharp 2.4.3
- Unity 2020.1.9f1
- .Net Core 3.1
Run Project
Server
Get the appropriate build from the release section and run it via command line. Alternatively you can also open the ENetServer Solution with the IDE of your choice and run it.
The server listens to Port 3333 and can be aborted by pressing any key.
Client
Either get the build for Android or Windows from the release section or open the project in Unity and run it (Make sure you started the server). Find out the ip of your server (127.0.0.1 if it is on the same machine), and click connect.
When connected successfully, you can enter messages in the box next to the send button. The messages will be broadcasted to all other clients that are online at that time.
Build Libraries
The libraries for android and iOS are already built for this repo, you can find them here.
If you want to build them yourself (or for a newer ENet version), take a look at the instructions below.
Android
- Download NDK (Or search for the version you use inside unity)
- Add the build folder inside to your path environment variables e.g
C:/Data/SDKs/android-ndk-r19c/build
- Clone
git@github.com:nxrighthere/ENet-CSharp.git
- Navigate to
ENet-CSharp/Source/Native
- Run
ndk-build
in that location. - Copy the folders
arm64-v8a
,armeabi-v7a
andx86
from the generated libs folder to your unity project toAssets/Enet/Plugins/Android/
. - Set
arm64-v8a
to ARM64,armeabi-v7a
to ARMv7 andx86
to x86.
iOS
- Install XCode
- Clone
git@github.com:nxrighthere/ENet-CSharp.git
- Navigate to
ENet-CSharp/Source/Native
- Run
sh build-ios.sh
- Copy
libenet.a
to your unity project toAssets/Enet/Plugins/iOS/libenet.a
- Set
libenet.a
to iOS only with CPU ARM64