diff --git a/README.md b/README.md index 01aee468..78c68a45 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# React Unity WebGL · []() []() []() []() []() []() +# React Unity WebGL · []() []() []() []() []() When building content for the web, you might need to communicate with other elements on React Application. Or you might want to implement functionality using Web APIs which [Unity](https://unity3d.com) does not currently expose by default. In both cases, you need to directly interface with the browser’s JavaScript engine. React Unity WebGL provides an easy library for Unity 5.6 / 2017 or newer with different methods to do this. diff --git a/library/modules/UnityEvent.js b/library/modules/UnityEvent.js index b6747570..5944236b 100644 --- a/library/modules/UnityEvent.js +++ b/library/modules/UnityEvent.js @@ -22,7 +22,7 @@ var UnityEvent = exports.UnityEvent = function () { _createClass(UnityEvent, [{ key: 'emit', value: function emit(parameter) { - if (this.canEmit() === true) _Unity.UnityInstance.SendMessage(this.gameObjectName, this.methodName, parameter || '');else console.warn('Wait for Unity to be instantiated before sending an event \'' + this.methodName + '\''); + if (this.canEmit() === true) _Unity.UnityInstance.SendMessage(this.gameObjectName, this.methodName, typeof parameter !== 'undefined' ? parameter : '');else console.warn('Wait for Unity to be instantiated before sending an event \'' + this.methodName + '\''); } }, { key: 'canEmit', diff --git a/package.json b/package.json index c68c66f0..3057afbc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-unity-webgl", - "version": "6.4.1", + "version": "6.4.2", "description": "A Unity WebGL component for your React application", "main": "library/index.js", "types": "./types.d.ts", @@ -34,4 +34,4 @@ "babel-preset-env": "1.6.1", "babel-preset-react": "6.24.1" } -} +} \ No newline at end of file diff --git a/source/components/Unity.js b/source/components/Unity.js index cc599892..b468d258 100644 --- a/source/components/Unity.js +++ b/source/components/Unity.js @@ -3,20 +3,20 @@ import UnityLoaderService from '../services/UnityLoaderService' import Styles from './Unity.styles' export default class Unity extends Component { - constructor (props) { - super (props) + constructor(props) { + super(props) this.state = { error: null } - this._unityLoaderService = new UnityLoaderService () + this._unityLoaderService = new UnityLoaderService() } - componentDidMount () { - this._instantiate () + componentDidMount() { + this._instantiate() } - componentWillUnmount () { - this._unityLoaderService.unmount () + componentWillUnmount() { + this._unityLoaderService.unmount() } - _instantiate () { + _instantiate() { let error = null if (typeof this.props.loader === 'undefined') error = 'Please provide Unity with a path to the UnityLoader in the loader prop.' @@ -24,38 +24,38 @@ export default class Unity extends Component { error = 'Please provide Unity with a path to a valid JSON in the src prop.' if (error !== null) { - console.error (error) - this.setState ({ error: error }) - } + console.error(error) + this.setState({ error: error }) + } else { - this._unityLoaderService.append (this.props.loader).then (() => { - let unityInstance = UnityLoader.instantiate ('unity', this.props.src, { - onProgress: this._onProgress.bind (this), - Module : this.props.module + this._unityLoaderService.append(this.props.loader).then(() => { + let unityInstance = UnityLoader.instantiate('unity', this.props.src, { + onProgress: this._onProgress.bind(this), + Module: this.props.module }) module.exports.UnityInstance = unityInstance }) } } - _onProgress (unityInstance, progression) { + _onProgress(unityInstance, progression) { if (typeof this.props.onProgress !== 'undefined') { - this.props.onProgress (progression) + this.props.onProgress(progression) } } - _getContainerStyles () { + _getContainerStyles() { return { width: this.props.width || '100%', height: this.props.height || '100%' } } - render () { + render() { return ( -