Unity component: pass additional properties to canvas #243
alexkuz
started this conversation in
Feature Requests
Replies: 1 comment
-
Hi. Sorry for my late response. I will add this to the wish list. A quick fix to achieve this now would be as following: import React, { useEffect } 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() {
useEffect(function () {
unityContext.on("canvas", function (canvas) {
canvas.setAttribute("role", "someRole");
canvas.setAttribute("aria-label", "someAriaLabel");
canvas.setAttribute("aria-roledescription", "someRoleDescription");
});
}, []);
return <Unity unityContext={unityContext} />;
} I hope this informs you enough. Happy coding! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Currently,
<Unity>
component only accepts a few of canvas element props (className, style, tabIndex), ignoring any other props.It would be nice if
<Unity>
could proxy other HTMLCanvasElement attributes to a canvas (I'm in particular interested in attributes likerole
,aria-label
andaria-roledescription
).Beta Was this translation helpful? Give feedback.
All reactions