this repo provides the basic functionality for starting voice chat with unity webgl games.
it handels the voice chat on the browser and exposes a set of functions to unity to be used for starting and ending voice sessions
the voice chat itself is handeled by socket.io which is based on Websocket
clone the repo using
git clone https://github.com/Gold3nEagle/UnityWebGLVoiceChatServer-Socket.io.git
pre-requsits: -
- npm
- node
- nodemon
to run the server use
npm run dev
you can add all the files of your build in the public folder of the project, make sure that the html page is called "index.html".
next, ensure that you put both the "client js" file and socket io cdn link at the bottom of the page like this
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js" integrity="sha384-/KNQL8Nu5gCHLqwqfQjA689Hhoqgi2S84SNUxC3roTe4EhJ9AfLkp8QiQcU8AMzI" crossorigin="anonymous"></script>
<script src="./js/client.js"></script>
</body>this is optional, for at the momment, the browser does not need to send message to the unity game instance
also make sure that you store your "unityInstance" variable on "window" variable like this
note: this section of the code is found with the build of the webgl game
}).then((unityInstance) => {
window.unityInstance = unityInstance;the two files in the UnityFiles Folder are meant to be used in your unity game.
those two files will allow unity to communicate with the browser where the jslib acts as the birdge and the WebVoiceChatHandler acts as the interface to use the features.
for more info check the wiki of the repo about the files.