Why isn't it rendering? #245
Replies: 6 comments 1 reply
-
Hi. Can you validate your canvas is actually being displayed on your screen? |
Beta Was this translation helpful? Give feedback.
-
Hi Jeffrey |
Beta Was this translation helpful? Give feedback.
-
Hi. Could you try providing a width and height for the canvas using styles or a className? Looking at your inspector, I think I know what's going wrong haha. The canvas should not scale itself to these enormous values. I will look into this, which browser and OS are you using? Let me know if setting the dimensions solves your problem. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
No, I meant adding these style properties to the Unity component itself. More like this: (See the documentation for further details) import React from "react";
import Unity, { UnityContext } from "react-unity-webgl";
const unityContext = new UnityContext({
loaderUrl: "build/myunityapp.loader.js",
dataUrl: "build/myunityapp.data",
frameworkUrl: "build/myunityapp.framework.js",
codeUrl: "build/myunityapp.wasm",
});
function App() {
return (
<Unity
unityContext={unityContext}
style={{
height: 600,
width: 950,
}}
/>
);
} |
Beta Was this translation helpful? Give feedback.
-
Yes, thank you @jeffreylanters. It worked in the demo project. |
Beta Was this translation helpful? Give feedback.
-
Can anyone please advise how to resolve what's going wrong here?
From Unity 2021, 'Build and Run' serves the files in a browser and works fine.


I import Unity's Build files to a basic React app, set paths (/public/) and used the demo code. Yet the webgl component stays black and throws some errors.
Prior error - WebGL-0x7fd8d3df0800]GL ERROR :GL_INVALID_VALUE : glTexStorage2D: dimensions out of range -
Beta Was this translation helpful? Give feedback.
All reactions