Closed determinationlove closed 1 year ago
Vanilla JavaScript
Local Development Server
When the Unity Component mounts
The problem seems related to my project
9.4.3
18.2.0
2022.3.6f1
I put the entire folder "WebGL" created by Unity into the src folder in the React project.
Error:
use-unity-arguments.js:15 Uncaught TypeError: Cannot read properties of undefined (reading 'dataUrl') at use-unity-arguments.js:15:55
It seems that all URLs are not set? However, console.log prints out unityProvider.unityProvider.unityConfig.dataUrl normally.
import { useEffect, useState } from "react"; import { Unity, useUnityContext } from "react-unity-webgl"; export default function CBT() { const unityProvider = useUnityContext({ loaderUrl: "/WebGL/Build/WebGL.loader.js", dataUrl: "/WebGL/Build/WebGL.data", frameworkUrl: "/WebGL/Build/WebGL.framework.js", codeUrl: "/WebGL/Build/WebGL.wasm", }); useEffect(() => { console.log(unityProvider.unityProvider.unityConfig.dataUrl); // Print out: /WebGL/Build/WebGL.data }, []); return ( <> <Unity unityProvider={unityProvider} style={{ width: 800, height: 600 }} /> </> ); }
I was so tired that I made a mistake and it has been fixed.
Please avoid duplicates
Language and Compiler
Vanilla JavaScript
What environment are you using?
Local Development Server
When does your problem occur?
When the Unity Component mounts
What does your problem relate to?
The problem seems related to my project
React-Unity-WebGL Version
9.4.3
React Version
18.2.0
Unity Version
2022.3.6f1
What happened?
I put the entire folder "WebGL" created by Unity into the src folder in the React project.
Error:
It seems that all URLs are not set? However, console.log prints out unityProvider.unityProvider.unityConfig.dataUrl normally.
Reproducible test case
Would you be interested in contributing a fix?