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.69k stars 160 forks source link

Using in collaboration with FMETP_STREAM 3.0 #509

Open dylan-infinitus opened 1 year ago

dylan-infinitus commented 1 year ago

Please avoid duplicates

Language and Compiler

Vanilla JavaScript

What environment are you using?

Local Development Server

When does your problem occur?

When the Unity App is running

What does your problem relate to?

The problem seems Browser related

React-Unity-WebGL Version

9.4.0

React Version

18.2.0

Unity Version

2022.1.19f1

What happened?

I am using react-unity-webgl in collaboration with another asset for streaming data: FMETP_STREAM 3.0.

Link to FMETP_STREAM 3.0 asset: https://assetstore.unity.com/packages/tools/video/fmetp-stream-3-0-221362

I have an existing Node.js server running on AWS which should relay messages between my clients. I have two versions: a mobile app built with Unity and a Unity WebGL version hosted within a React app.

When I run the build output of the Unity WebGL within the Unity generated local server, everything works as expected. Although, when I embed the Unity app within a React app using react-unity-webgl my WebGL app doesn't decode the byte data being relayed back from the Node.js server (sent from the mobile app).

Is this an issue with how react-unity-webgl handles the WebGL embedding within my React app?

I have noticed that building via the Unity "Build and Run" method while using the Minimal template does not work either. Only the Default or PWA templates work correctly.

Reproducible test case

  1. Download FMETP_STREAM 3.0 asset and follow the simple instructions to create a test scene
  2. Run the local Node.js server provided with the asset
  3. Build one version of your scene to embed within a React app
  4. Run the second version within Editor or a mobile device (doesn't matter which you choose)
  5. View the logs in the browser as it shows data being retrieved but not decoded by the app

Would you be interested in contributing a fix?

thedrhax14 commented 11 months ago

It is maybe related to additional files that must be included in the header of the html file. It may worth to check if the asset comes with extra js files that should be included. We had a similar issue with AVPro to support live streams, so, we had to include an external js module for hls in the header of index.html so that live streaming videos work. Maybe it is the same for FMETP but different js module