Skip to content

Commit 1d97039

Browse files
Added unique element id per Unity canvas to prevent issues in Unity 2021.2
1 parent 937bf5b commit 1d97039

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/components/unity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ export class Unity extends PureComponent<IUnityProps, {}> {
120120
_unityInstanceParameters,
121121
this.onProgress.bind(this)
122122
);
123+
// We increment the unique identifier counter to avoid conflicts.
124+
Unity.uniqueIdentifiers++;
123125
// Finally pass the instance back to the context object.
124126
this.unityContext.setUnityInstance(_unityInstance);
125127
// Since the creation of the Unity Instance is async, we'll check the
@@ -143,7 +145,7 @@ export class Unity extends PureComponent<IUnityProps, {}> {
143145
*/
144146
public render(): React.ReactNode {
145147
return createElement("canvas", {
146-
id: `unity-canvas-${Unity.uniqueIdentifiers++}`,
148+
id: `unity-canvas-${Unity.uniqueIdentifiers}`,
147149
ref: (ref: HTMLCanvasElement) => (this.htmlCanvasElementReference = ref),
148150
className: this.props.className || "",
149151
tabIndex: this.props.tabIndex || undefined,

0 commit comments

Comments
 (0)