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.75k stars 162 forks source link

ReactUnityWebGL is not defined #429

Closed sunlili810 closed 2 years ago

sunlili810 commented 2 years ago

Please avoid duplicates

Language and Compiler

Vanilla JavaScript

What environment are you using?

Static File Serving

When does your problem occur?

While writing code

What does your problem relate to?

The problem seems Unity related

React-Unity-WebGL Version

9.0.4

React Version

17.0.0

Unity Version

2020.3

What happened?

mergeInto(LibraryManager.library, {  HelloFn: function (userName, score) {    ReactUnityWebGL.HelloFn(Pointer_stringify(userName), score); }, });

Reproducible test case

No response

Would you be interested in contributing a fix?

jeffreylanters commented 2 years ago

The ReactUnityWebGL object is only available in version 8. This is replaced with the dispatchReactUnityEvent method in version 9.

Read more: https://react-unity-webgl.dev/docs/api/event-system

sunlili810 commented 2 years ago

The ReactUnityWebGL object is only available in version 8. This is replaced with the dispatchReactUnityEvent method in version 9.

Read more: https://react-unity-webgl.dev/docs/api/event-system

I rolled back the version to 8.8.0 and solved this problem.Thanks a lot!

jeffreylanters commented 2 years ago

Awesome! Happy coding.