Skip to content

Commit ca5c378

Browse files
Typing
1 parent 67bda36 commit ca5c378

File tree

14 files changed

+77
-32
lines changed

14 files changed

+77
-32
lines changed

lib/Styles.js renamed to lib/components/Styles.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
/**
7+
* Static styles used by the Unity component
8+
*/
69
exports.default = {
710
unity: {
811
width: '100%',

lib/Unity.js renamed to lib/components/Unity.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var _react = require('react');
1010

1111
var _react2 = _interopRequireDefault(_react);
1212

13-
var _UnityLoaderService = require('./UnityLoaderService');
13+
var _UnityLoaderService = require('../services/UnityLoaderService');
1414

1515
var _UnityLoaderService2 = _interopRequireDefault(_UnityLoaderService);
1616

@@ -37,53 +37,52 @@ var Unity = function (_Component) {
3737
_this.state = {
3838
error: null
3939
};
40-
_this.unityLoaderService = new _UnityLoaderService2.default();
40+
_this._unityLoaderService = new _UnityLoaderService2.default();
4141
return _this;
4242
}
4343

4444
_createClass(Unity, [{
4545
key: 'componentDidMount',
4646
value: function componentDidMount() {
47-
this.instantiate();
47+
this._instantiate();
4848
}
4949
}, {
5050
key: 'componentWillUnmount',
5151
value: function componentWillUnmount() {
52-
this.unityLoaderService.unmount();
52+
this._unityLoaderService.unmount();
5353
}
5454
}, {
55-
key: 'instantiate',
56-
value: function instantiate() {
55+
key: '_instantiate',
56+
value: function _instantiate() {
5757
var _this2 = this;
5858

5959
var error = null;
60-
6160
if (typeof this.props.loader === 'undefined') error = 'Please provide Unity with a path to the UnityLoader in the loader prop.';
6261
if (typeof this.props.src === 'undefined') error = 'Please provide Unity with a path to a valid JSON in the src prop.';
6362

6463
if (error !== null) {
6564
console.error(error);
6665
this.setState({ error: error });
6766
} else {
68-
this.unityLoaderService.append(this.props.loader).then(function () {
67+
this._unityLoaderService.append(this.props.loader).then(function () {
6968
var unityInstance = UnityLoader.instantiate('unity', _this2.props.src, {
70-
onProgress: _this2.onProgress.bind(_this2),
69+
onProgress: _this2._onProgress.bind(_this2),
7170
Module: _this2.props.module
7271
});
7372
module.exports.UnityInstance = unityInstance;
7473
});
7574
}
7675
}
7776
}, {
78-
key: 'onProgress',
79-
value: function onProgress(unityInstance, progression) {
77+
key: '_onProgress',
78+
value: function _onProgress(unityInstance, progression) {
8079
if (typeof this.props.onProgress !== 'undefined') {
8180
this.props.onProgress(progression);
8281
}
8382
}
8483
}, {
85-
key: 'getContainerStyles',
86-
value: function getContainerStyles() {
84+
key: '_getContainerStyles',
85+
value: function _getContainerStyles() {
8786
return {
8887
width: this.props.width || '100%',
8988
height: this.props.height || '100%'
@@ -94,7 +93,7 @@ var Unity = function (_Component) {
9493
value: function render() {
9594
return _react2.default.createElement(
9695
'div',
97-
{ className: 'unity', style: this.getContainerStyles() },
96+
{ className: 'unity', style: this._getContainerStyles() },
9897
this.state.error !== null ? _react2.default.createElement(
9998
'b',
10099
null,

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
55
});
66
exports.SendMessage = exports.RegisterExternalListener = undefined;
77

8-
var _Unity = require('./Unity');
8+
var _Unity = require('./components/Unity');
99

1010
var _Unity2 = _interopRequireDefault(_Unity);
1111

12-
var _RegisterExternalListener = require('./RegisterExternalListener');
12+
var _RegisterExternalListener = require('./modules/RegisterExternalListener');
1313

14-
var _SendMessage = require('./SendMessage');
14+
var _SendMessage = require('./modules/SendMessage');
1515

1616
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1717

File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"name": "react-unity-webgl",
33
"version": "6.2.2",
44
"description": "A Unity WebGL component for your React application",
5-
"main": "lib/index.js",
5+
"main": "library/index.js",
6+
"types": "source/types.d.ts",
67
"scripts": {
78
"compile": "babel --presets react source --out-dir lib"
89
},

source/Styles.js renamed to source/components/Styles.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Static styles used by the Unity component
3+
*/
14
export default {
25
unity: {
36
width: '100%',

source/Unity.js renamed to source/components/Unity.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { Component } from 'react'
2-
import UnityLoaderService from './UnityLoaderService'
2+
import UnityLoaderService from '../services/UnityLoaderService'
33
import Styles from './Styles'
44

55
export default class Unity extends Component {
@@ -8,17 +8,16 @@ export default class Unity extends Component {
88
this.state = {
99
error: null
1010
}
11-
this.unityLoaderService = new UnityLoaderService ()
11+
this._unityLoaderService = new UnityLoaderService ()
1212
}
1313
componentDidMount () {
14-
this.instantiate ()
14+
this._instantiate ()
1515
}
1616
componentWillUnmount () {
17-
this.unityLoaderService.unmount ()
17+
this._unityLoaderService.unmount ()
1818
}
19-
instantiate () {
19+
_instantiate () {
2020
let error = null
21-
2221
if (typeof this.props.loader === 'undefined')
2322
error = 'Please provide Unity with a path to the UnityLoader in the loader prop.'
2423
if (typeof this.props.src === 'undefined')
@@ -29,29 +28,29 @@ export default class Unity extends Component {
2928
this.setState ({ error: error })
3029
}
3130
else {
32-
this.unityLoaderService.append (this.props.loader).then (() => {
31+
this._unityLoaderService.append (this.props.loader).then (() => {
3332
let unityInstance = UnityLoader.instantiate ('unity', this.props.src, {
34-
onProgress: this.onProgress.bind (this),
33+
onProgress: this._onProgress.bind (this),
3534
Module : this.props.module
3635
})
3736
module.exports.UnityInstance = unityInstance
3837
})
3938
}
4039
}
41-
onProgress (unityInstance, progression) {
40+
_onProgress (unityInstance, progression) {
4241
if (typeof this.props.onProgress !== 'undefined') {
4342
this.props.onProgress (progression)
4443
}
4544
}
46-
getContainerStyles () {
45+
_getContainerStyles () {
4746
return {
4847
width: this.props.width || '100%',
4948
height: this.props.height || '100%'
5049
}
5150
}
5251
render () {
5352
return (
54-
<div className='unity' style={this.getContainerStyles ()}>
53+
<div className='unity' style={this._getContainerStyles ()}>
5554
{this.state.error !== null ? (
5655
<b>React-Unity-Webgl error {this.state.error}</b>
5756
):(

source/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import Unity from './Unity'
2-
import { RegisterExternalListener } from './RegisterExternalListener'
3-
import { SendMessage } from './SendMessage'
1+
import Unity from './components/Unity'
2+
import { RegisterExternalListener } from './modules/RegisterExternalListener'
3+
import { SendMessage } from './modules/SendMessage'
44

55
export default Unity
66
export { RegisterExternalListener, SendMessage }

0 commit comments

Comments
 (0)