@@ -3,16 +3,6 @@ import { isBrowserEnvironment } from "../constants/is-browser-environment";
3
3
import { UnityLoaderStatus } from "../enums/unity-loader-status" ;
4
4
import { UnityConfig } from "../exports" ;
5
5
6
- interface ScriptData {
7
- count : number ;
8
- status : UnityLoaderStatus ;
9
- handleLoad ?: ( ) => void ;
10
- handleError ?: ( ) => void ;
11
- }
12
-
13
- // Map to track script references, status, and event handlers.
14
- const scriptReferenceMap = new Map < string , ScriptData > ( ) ;
15
-
16
6
/**
17
7
* Hook to embed a Unity Loader script.
18
8
* @param source The source of the unity loader.
@@ -28,12 +18,12 @@ const useUnityLoader = (unityConfig: UnityConfig): UnityLoaderStatus => {
28
18
// this scenario, the window is not available. We can't create a Unity
29
19
// Loader in this case.
30
20
if ( isBrowserEnvironment === false ) {
31
- return undefined ;
21
+ return ;
32
22
}
33
23
// If the script's source is null, we'll reset the status to idle.
34
24
if ( unityConfig . loaderUrl === null ) {
35
25
setStatus ( UnityLoaderStatus . Idle ) ;
36
- return undefined ;
26
+ return ;
37
27
}
38
28
/**
39
29
* Find existing script element by source. It may have been added by
@@ -88,7 +78,7 @@ const useUnityLoader = (unityConfig: UnityConfig): UnityLoaderStatus => {
88
78
if ( script !== null ) {
89
79
script . removeEventListener ( "load" , setStateFromEvent ) ;
90
80
script . removeEventListener ( "error" , setStateFromEvent ) ;
91
- script . remove ( ) ;
81
+ window . document . body . removeChild ( script ) ;
92
82
}
93
83
} ;
94
84
} , [ unityConfig . loaderUrl ] ) ;
0 commit comments