Skip to content

Commit 754c0f5

Browse files
Reformatted
1 parent fc3ab92 commit 754c0f5

File tree

5 files changed

+49
-49
lines changed

5 files changed

+49
-49
lines changed

source/components/Unity.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,59 @@ import UnityLoaderService from '../services/UnityLoaderService'
33
import Styles from './Unity.styles'
44

55
export default class Unity extends Component {
6-
constructor (props) {
7-
super (props)
6+
constructor(props) {
7+
super(props)
88
this.state = {
99
error: null
1010
}
11-
this._unityLoaderService = new UnityLoaderService ()
11+
this._unityLoaderService = new UnityLoaderService()
1212
}
13-
componentDidMount () {
14-
this._instantiate ()
13+
componentDidMount() {
14+
this._instantiate()
1515
}
16-
componentWillUnmount () {
17-
this._unityLoaderService.unmount ()
16+
componentWillUnmount() {
17+
this._unityLoaderService.unmount()
1818
}
19-
_instantiate () {
19+
_instantiate() {
2020
let error = null
2121
if (typeof this.props.loader === 'undefined')
2222
error = 'Please provide Unity with a path to the UnityLoader in the loader prop.'
2323
if (typeof this.props.src === 'undefined')
2424
error = 'Please provide Unity with a path to a valid JSON in the src prop.'
2525

2626
if (error !== null) {
27-
console.error (error)
28-
this.setState ({ error: error })
29-
}
27+
console.error(error)
28+
this.setState({ error: error })
29+
}
3030
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
3535
})
3636
module.exports.UnityInstance = unityInstance
3737
})
3838
}
3939
}
40-
_onProgress (unityInstance, progression) {
40+
_onProgress(unityInstance, progression) {
4141
if (typeof this.props.onProgress !== 'undefined') {
42-
this.props.onProgress (progression)
42+
this.props.onProgress(progression)
4343
}
4444
}
45-
_getContainerStyles () {
45+
_getContainerStyles() {
4646
return {
4747
width: this.props.width || '100%',
4848
height: this.props.height || '100%'
4949
}
5050
}
51-
render () {
51+
render() {
5252
return (
53-
<div className='unity' style={this._getContainerStyles ()}>
53+
<div className='unity' style={this._getContainerStyles()}>
5454
{this.state.error !== null ? (
5555
<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+
)}
5959
</div>
6060
)
6161
}

source/modules/RegisterExternalListener.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function RegisterExternalListener (methodName, callback) {
1+
export function RegisterExternalListener(methodName, callback) {
22
/**
33
* LEGACY
44
* bind the function to the window to allow
@@ -7,7 +7,7 @@ export function RegisterExternalListener (methodName, callback) {
77
* Application.ExternalEval.
88
*/
99
window[methodName] = parameter => {
10-
callback (parameter)
10+
callback(parameter)
1111
}
1212

1313
/**
@@ -18,6 +18,6 @@ export function RegisterExternalListener (methodName, callback) {
1818
if (typeof window.ReactUnityWebGL === 'undefined')
1919
window.ReactUnityWebGL = {}
2020
window.ReactUnityWebGL[methodName] = parameter => {
21-
callback (parameter)
21+
callback(parameter)
2222
}
2323
}

source/modules/SendMessage.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { UnityInstance } from '../components/Unity'
22

3-
export function SendMessage (gameObjectName, methodName, paramterValue) {
4-
console.warn (`SendMessage is deprecated since version 6.4.0, use UnityEvent instead.`)
3+
export function SendMessage(gameObjectName, methodName, paramterValue) {
4+
console.warn(`SendMessage is deprecated since version 6.4.0, use UnityEvent instead.`)
55
if (typeof UnityInstance !== 'undefined')
6-
UnityInstance.SendMessage (
7-
gameObjectName,
8-
methodName,
6+
UnityInstance.SendMessage(
7+
gameObjectName,
8+
methodName,
99
paramterValue || '')
1010
else
11-
console.warn (`Wait for Unity to be instantiated before sending a message to '${gameObjectName}'`)
11+
console.warn(`Wait for Unity to be instantiated before sending a message to '${gameObjectName}'`)
1212
}

source/modules/UnityEvent.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { UnityInstance } from '../components/Unity'
22

33
export class UnityEvent {
4-
constructor (gameObjectName, methodName) {
4+
constructor(gameObjectName, methodName) {
55
this.gameObjectName = gameObjectName
66
this.methodName = methodName
77
}
8-
emit (parameter) {
9-
if (this.canEmit () === true)
10-
UnityInstance.SendMessage (
11-
this.gameObjectName,
12-
this.methodName,
8+
emit(parameter) {
9+
if (this.canEmit() === true)
10+
UnityInstance.SendMessage(
11+
this.gameObjectName,
12+
this.methodName,
1313
parameter || '')
1414
else
15-
console.warn (`Wait for Unity to be instantiated before sending an event '${this.methodName}'`)
15+
console.warn(`Wait for Unity to be instantiated before sending an event '${this.methodName}'`)
1616
}
17-
canEmit () {
17+
canEmit() {
1818
return typeof UnityInstance !== 'undefined'
1919
}
2020
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
export default class UnityLoaderService {
2-
constructor () {
3-
this.documentHead = document.getElementsByTagName ('head')[0]
2+
constructor() {
3+
this.documentHead = document.getElementsByTagName('head')[0]
44
this.unityLoaderScript = null
55
}
6-
append (src) {
7-
return new Promise ((resolve, reject) => {
8-
this.unityLoaderScript = document.createElement ('script')
6+
append(src) {
7+
return new Promise((resolve, reject) => {
8+
this.unityLoaderScript = document.createElement('script')
99
this.unityLoaderScript.type = 'text/javascript'
1010
this.unityLoaderScript.async = true
1111
this.unityLoaderScript.src = src
1212
this.unityLoaderScript.onload = () => {
13-
resolve ()
13+
resolve()
1414
}
15-
this.documentHead.appendChild (this.unityLoaderScript)
15+
this.documentHead.appendChild(this.unityLoaderScript)
1616
})
1717
}
18-
unmount () {
18+
unmount() {
1919
if (this.unityLoaderScript !== null) {
20-
this.documentHead.removeChild (this.unityLoaderScript)
20+
this.documentHead.removeChild(this.unityLoaderScript)
2121
}
2222
}
2323
}

0 commit comments

Comments
 (0)