Sample unity3d project to demonstrate WebRTC official unity plugin. with simple WebRTC signaling implemented with Socket.IO.
- Unity3D 2017.3+
- node.js
-
WebRTC (official) unity plugin: https://github.com/mhama/webrtc-dev-env
-
Socket.IO
library: https://github.com/floatinghotpot/socket.io-unity
- On Windows:
> server.bat
or
- On Mac/Linux
npm install
node index.js
- Output Log
>call npm install
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
...
listening on *:3000
forwarding to global domain...
ngrok server: https://440ab904.ngrok.io
- The last "ngrok server" part is IMPORTANT!
- the server URL lasts for 24 hours only. After that, you need to restart server for another 24 hours.
build and run
unity project.
- set the above
ngrok server
URL to app's server URL field. (but use http:// rather than https://) - push
Connect
button - push
Offer with Camera
button
- browse the above
ngrok server
URL with web browser. (the web browser needs to support WebRTC). - push
Start Camera
button - push
Start Peer
button
This sample use signaling with http long polling of Socket.IO. Very dirty implementation that doesnot handle bad states or errors.
Beware that WebRTC may use very much bandwidth! Beware especially if you are not using fixed price connection.