Skip to content

Commit 937bf5b

Browse files
Added a unique identifier to the unity canvas
1 parent afdfbe3 commit 937bf5b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/components/unity.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ import { IUnityInstanceParameters } from "../interfaces/unity-instance-parameter
66

77
// TODO turn into functional component
88
export class Unity extends PureComponent<IUnityProps, {}> {
9+
/**
10+
* A counter to track the number of times a unique identifier was generated.
11+
*/
12+
private static uniqueIdentifiers: number = 0;
13+
914
/**
1015
* The UnityContext passed by the props.
1116
* @private
@@ -138,6 +143,7 @@ export class Unity extends PureComponent<IUnityProps, {}> {
138143
*/
139144
public render(): React.ReactNode {
140145
return createElement("canvas", {
146+
id: `unity-canvas-${Unity.uniqueIdentifiers++}`,
141147
ref: (ref: HTMLCanvasElement) => (this.htmlCanvasElementReference = ref),
142148
className: this.props.className || "",
143149
tabIndex: this.props.tabIndex || undefined,

0 commit comments

Comments
 (0)