Skip to content

Commit 5885fdc

Browse files
author
Jeffrey Lanters
authored
Merge pull request #26 from jeffreylanters/development
Component doesn't unmount properly #22
2 parents d983f8f + 07d1ea1 commit 5885fdc

File tree

6 files changed

+19
-25
lines changed

6 files changed

+19
-25
lines changed

library/components/Unity.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ var _UnityLoaderService = require('../services/UnityLoaderService');
1414

1515
var _UnityLoaderService2 = _interopRequireDefault(_UnityLoaderService);
1616

17-
var _Unity = require('./Unity.styles');
18-
19-
var _Unity2 = _interopRequireDefault(_Unity);
20-
2117
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2218

2319
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -65,11 +61,12 @@ var Unity = function (_Component) {
6561
this.setState({ error: error });
6662
} else {
6763
this._unityLoaderService.append(this.props.loader).then(function () {
68-
var unityInstance = UnityLoader.instantiate('unity', _this2.props.src, {
64+
var unityInstance = UnityLoader.instantiate('__ruw', _this2.props.src, {
6965
onProgress: _this2._onProgress.bind(_this2),
7066
Module: _this2.props.module
7167
});
7268
module.exports.UnityInstance = unityInstance;
69+
window._ui = unityInstance;
7370
});
7471
}
7572
}
@@ -99,7 +96,7 @@ var Unity = function (_Component) {
9996
null,
10097
'React-Unity-Webgl error ',
10198
this.state.error
102-
) : _react2.default.createElement('div', { style: _Unity2.default.unity, id: 'unity' })
99+
) : _react2.default.createElement('div', { style: { width: '100%', height: '100%' }, id: '__ruw' })
103100
);
104101
}
105102
}]);

library/services/UnityLoaderService.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ var UnityLoaderService = function () {
3535
}, {
3636
key: 'unmount',
3737
value: function unmount() {
38-
if (this.unityLoaderScript !== null) {
39-
this.documentHead.removeChild(this.unityLoaderScript);
40-
}
38+
/// unmounting is disabled due to bug
39+
/// https://github.com/jeffreylanters/react-unity-webgl/issues/22
40+
// if (this.unityLoaderScript !== null) {
41+
// this.documentHead.removeChild(this.unityLoaderScript)
42+
// }
4143
}
4244
}]);
4345

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-unity-webgl",
3-
"version": "6.4.3",
3+
"version": "6.4.4",
44
"description": "A Unity WebGL component for your React application",
55
"main": "library/index.js",
66
"types": "./types.d.ts",

source/components/Unity.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from 'react'
22
import UnityLoaderService from '../services/UnityLoaderService'
3-
import Styles from './Unity.styles'
43

54
export default class Unity extends Component {
65
constructor(props) {
@@ -29,7 +28,7 @@ export default class Unity extends Component {
2928
}
3029
else {
3130
this._unityLoaderService.append(this.props.loader).then(() => {
32-
let unityInstance = UnityLoader.instantiate('unity', this.props.src, {
31+
let unityInstance = UnityLoader.instantiate('__ruw', this.props.src, {
3332
onProgress: this._onProgress.bind(this),
3433
Module: this.props.module
3534
})
@@ -51,11 +50,11 @@ export default class Unity extends Component {
5150
render() {
5251
return (
5352
<div className='unity' style={this._getContainerStyles()}>
54-
{this.state.error !== null ? (
53+
{this.state.error !== null ?
5554
<b>React-Unity-Webgl error {this.state.error}</b>
56-
) : (
57-
<div style={Styles.unity} id='unity'></div>
58-
)}
55+
:
56+
<div style={{ width: '100%', height: '100%' }} id='__ruw'></div>
57+
}
5958
</div>
6059
)
6160
}

source/components/Unity.styles.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

source/services/UnityLoaderService.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ export default class UnityLoaderService {
1616
})
1717
}
1818
unmount() {
19-
if (this.unityLoaderScript !== null) {
20-
this.documentHead.removeChild(this.unityLoaderScript)
21-
}
19+
/// unmounting is disabled due to bug
20+
/// https://github.com/jeffreylanters/react-unity-webgl/issues/22
21+
// if (this.unityLoaderScript !== null) {
22+
// this.documentHead.removeChild(this.unityLoaderScript)
23+
// }
2224
}
2325
}

0 commit comments

Comments
 (0)