jeffreylanters / react-unity-webgl

React Unity WebGL provides a modern solution for embedding Unity WebGL builds in your React Application while providing advanced APIs for two way communication and interaction between Unity and React.
https://react-unity-webgl.dev
Apache License 2.0
1.7k stars 160 forks source link

Audio working in non-react WebGL build but not when using React-Unity to serve files. #445

Closed 0xDragonfly closed 1 year ago

0xDragonfly commented 1 year ago

Please avoid duplicates

Language and Compiler

Babel and WebPack JavaScript

What environment are you using?

Static File Serving

When does your problem occur?

When the Unity App starts

What does your problem relate to?

The problem seems React related

React-Unity-WebGL Version

9.0.4

React Version

18.2.0

Unity Version

2021.3.2f1

What happened?

Audio from Unity builds rendered via React-Unity context doesn't seem to output audio. However, the same build when hosted by itself (or using "Build and Run" option from Unity) has the audio working without problems. Standalone builds on Windows and Linux also have correct sound output.

Audio files used were MP3 and WAV formats which are supported by browsers out of the box, managed via a single Audio Source component per scene, with the Audio Listener attached to the Main Camera. Since audio works on regular hosted WebGL builds, this points to a bug with the way the Unity Context rendered by the React-Unity context container.

No errors or warning messages on bowser console for both builds.

Tested with same results across these browsers: Chrome, Brave, Firefox and Safari.

Reproducible test case

No response

Would you be interested in contributing a fix?

0xDragonfly commented 1 year ago

Fixed the issue. Was using an older version of the build files instead of the new ones where audio was added. Swapped them out, works as intended. Closing this issue now!