Skip to content

Commit 7174b9e

Browse files
author
Jeffrey Lanters
authored
Merge pull request #85 from elraccoone/feature/optional-unity-loader
Feature/optional unity loader
2 parents b6790c3 + 82d0de5 commit 7174b9e

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

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": "7.1.9",
3+
"version": "7.1.10",
44
"description": "React Unity WebGL provides an easy solution for embedding Unity WebGL builds in your React application, with two-way communication between your React and Unity application with advanced API's.",
55
"main": "./distribution/Exports.js",
66
"scripts": {

source/components/Unity.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,14 @@ export default class Unity extends React.Component<IUnityProps, IUnityState> {
8585
* @private
8686
*/
8787
private adjustCanvasToContainer(): void {
88-
const _width = this.htmlElement!.offsetWidth;
89-
const _height = this.htmlElement!.offsetHeight;
90-
const _canvas = this.htmlElement!.getElementsByTagName("canvas")[0];
91-
if (_canvas != null) {
92-
if (_canvas.height !== _height) {
88+
if (typeof this.htmlElement !== "undefined") {
89+
const _width = this.htmlElement.offsetWidth;
90+
const _height = this.htmlElement.offsetHeight;
91+
const _canvas = this.htmlElement.getElementsByTagName("canvas")[0];
92+
if (typeof _canvas !== "undefined" && _canvas.height !== _height)
9393
_canvas.height = _height;
94-
}
95-
if (_canvas.width !== _width) {
94+
if (typeof _canvas !== "undefined" && _canvas.width !== _width)
9695
_canvas.width = _width;
97-
}
9896
}
9997
}
10098

source/declarations/UnityVersion.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
export type UnityVersion =
22
| "undefined"
3+
| "2019.2.18"
4+
| "2019.2.17"
5+
| "2019.2.16"
6+
| "2019.2.15"
7+
| "2019.2.14"
8+
| "2019.2.13"
9+
| "2019.2.12"
310
| "2019.2.11"
411
| "2019.2.10"
512
| "2019.2.9"

0 commit comments

Comments
 (0)