Unity and WebSocket

Akshay Kale
2 min readSep 4, 2018

--

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.)

--

--

No responses yet