Skip to content

Commit 0758722

Browse files
Fixed an issue where the window was force accessed
1 parent 099191a commit 0758722

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

source/hooks/use-unity-instance.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ export function useUnityInstance(
4141
// Creates the Unity Instance, this method is made available globally by
4242
// the Unity Loader.
4343
try {
44+
// It is possible for the application being rendered server side. In
45+
// this scenario, the window is not available. We can't create the
46+
// Unity Instance in this case.
47+
if (window === undefined) {
48+
return;
49+
}
4450
const unityInstance = await window.createUnityInstance(
4551
htmlCanvasElement,
4652
unityInstanceParameters,

0 commit comments

Comments
 (0)