@@ -3,59 +3,59 @@ import UnityLoaderService from '../services/UnityLoaderService'
3
3
import Styles from './Unity.styles'
4
4
5
5
export default class Unity extends Component {
6
- constructor ( props ) {
7
- super ( props )
6
+ constructor ( props ) {
7
+ super ( props )
8
8
this . state = {
9
9
error : null
10
10
}
11
- this . _unityLoaderService = new UnityLoaderService ( )
11
+ this . _unityLoaderService = new UnityLoaderService ( )
12
12
}
13
- componentDidMount ( ) {
14
- this . _instantiate ( )
13
+ componentDidMount ( ) {
14
+ this . _instantiate ( )
15
15
}
16
- componentWillUnmount ( ) {
17
- this . _unityLoaderService . unmount ( )
16
+ componentWillUnmount ( ) {
17
+ this . _unityLoaderService . unmount ( )
18
18
}
19
- _instantiate ( ) {
19
+ _instantiate ( ) {
20
20
let error = null
21
21
if ( typeof this . props . loader === 'undefined' )
22
22
error = 'Please provide Unity with a path to the UnityLoader in the loader prop.'
23
23
if ( typeof this . props . src === 'undefined' )
24
24
error = 'Please provide Unity with a path to a valid JSON in the src prop.'
25
25
26
26
if ( error !== null ) {
27
- console . error ( error )
28
- this . setState ( { error : error } )
29
- }
27
+ console . error ( error )
28
+ this . setState ( { error : error } )
29
+ }
30
30
else {
31
- this . _unityLoaderService . append ( this . props . loader ) . then ( ( ) => {
32
- let unityInstance = UnityLoader . instantiate ( 'unity' , this . props . src , {
33
- onProgress : this . _onProgress . bind ( this ) ,
34
- Module : this . props . module
31
+ this . _unityLoaderService . append ( this . props . loader ) . then ( ( ) => {
32
+ let unityInstance = UnityLoader . instantiate ( 'unity' , this . props . src , {
33
+ onProgress : this . _onProgress . bind ( this ) ,
34
+ Module : this . props . module
35
35
} )
36
36
module . exports . UnityInstance = unityInstance
37
37
} )
38
38
}
39
39
}
40
- _onProgress ( unityInstance , progression ) {
40
+ _onProgress ( unityInstance , progression ) {
41
41
if ( typeof this . props . onProgress !== 'undefined' ) {
42
- this . props . onProgress ( progression )
42
+ this . props . onProgress ( progression )
43
43
}
44
44
}
45
- _getContainerStyles ( ) {
45
+ _getContainerStyles ( ) {
46
46
return {
47
47
width : this . props . width || '100%' ,
48
48
height : this . props . height || '100%'
49
49
}
50
50
}
51
- render ( ) {
51
+ render ( ) {
52
52
return (
53
- < div className = 'unity' style = { this . _getContainerStyles ( ) } >
53
+ < div className = 'unity' style = { this . _getContainerStyles ( ) } >
54
54
{ this . state . error !== null ? (
55
55
< b > React-Unity-Webgl error { this . state . error } </ b >
56
- ) : (
57
- < div style = { Styles . unity } id = 'unity' > </ div >
58
- ) }
56
+ ) : (
57
+ < div style = { Styles . unity } id = 'unity' > </ div >
58
+ ) }
59
59
</ div >
60
60
)
61
61
}
0 commit comments