Unity and WebSocket

Akshay Kale
Sep 4, 2018 · 2 min read

Communicate with the websocket in unity-3d.

Use WebSocket-Sharp library to implement websockets in Unity.

OPTION 1 : Generate the .dll file

> Clone the repo from github: https://github.com/sta/websocket-sharp

git clone https://github.com/sta/websocket-sharp.git
cd websocket-sharp

> Open it with MonoDevelop (double click on websocket-sharp.sln file)

> Remove the Folders “Example, Example1, Example2, Example3” from the visual studio. Select these folders -> right click ->remove.

> In Visual Studio, change the build method to “Release”

> Build the project. Once build is successful the “websocket-sharp.dll” should be generated in the /bin/Release/websocket-sharp.dll .

> Copy this .dll file in your Assets/Plugins folder in Unity.

Option 2: Install using Package manager

> Unity has a open source package manager called NuGet.

> Head to asset store (https://assetstore.unity.com/packages/tools/utilities/nuget-for-unity-104640) . Download and import this asset.

> Then search for WebsocketSharp and hit install button. (In my case it is already installed. You should see the install button.)

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade