react-unity-webgl
Advanced tools
Comparing version 8.0.1 to 8.0.2
@@ -7,3 +7,3 @@ import "../declarations/unityInstance"; | ||
/** | ||
* The Unity context passed by the props. | ||
* The UnityContext passed by the props. | ||
* @type {UnityContext} | ||
@@ -13,3 +13,3 @@ */ | ||
/** | ||
* The Unity Loader service instance. | ||
* The UnityLoader service instance. | ||
* @type {UnityLoaderService} | ||
@@ -23,6 +23,5 @@ */ | ||
/** | ||
* An event that is triggered by the Unity player. This tracks | ||
* the loading progression of the player. It will send '1' when | ||
* the loading is completed. | ||
* @param {UnityInstance} unityInstance | ||
* Event invoked by the UnityInstance when the initialization is progressing. | ||
* Will be used to track the loading progression and invokes the event listeners | ||
* for both 'progress' and 'loaded' when the progression hits a value of '1'. | ||
* @param {number} progression | ||
@@ -32,13 +31,18 @@ */ | ||
/** | ||
* Initialzied the Unity player when the component is mounted. | ||
* Event invoked when the component is mounted. This sets the component | ||
* reference and starts the mounting of the UnityInstance. | ||
*/ | ||
componentDidMount(): Promise<void>; | ||
componentDidMount(): void; | ||
/** | ||
* When the component will be unmounted, the UnityInstance will quit. | ||
* Event invoked when the component will unmount. This force quits the | ||
* UnityInstance which will clear it from the memory. | ||
*/ | ||
componentWillUnmount(): void; | ||
/** | ||
* Initialized the Unity Loader and mounts the UnityInstance to the component. | ||
*/ | ||
private mountUnityInstance; | ||
/** | ||
* Renders the unity wrapper and player. | ||
* @returns {React.ReactNode} element | ||
* @public | ||
*/ | ||
@@ -45,0 +49,0 @@ render(): React.ReactNode; |
@@ -64,3 +64,3 @@ "use strict"; | ||
/** | ||
* The Unity context passed by the props. | ||
* The UnityContext passed by the props. | ||
* @type {UnityContext} | ||
@@ -70,3 +70,3 @@ */ | ||
/** | ||
* The Unity Loader service instance. | ||
* The UnityLoader service instance. | ||
* @type {UnityLoaderService} | ||
@@ -78,6 +78,5 @@ */ | ||
/** | ||
* An event that is triggered by the Unity player. This tracks | ||
* the loading progression of the player. It will send '1' when | ||
* the loading is completed. | ||
* @param {UnityInstance} unityInstance | ||
* Event invoked by the UnityInstance when the initialization is progressing. | ||
* Will be used to track the loading progression and invokes the event listeners | ||
* for both 'progress' and 'loaded' when the progression hits a value of '1'. | ||
* @param {number} progression | ||
@@ -92,11 +91,26 @@ */ | ||
/** | ||
* Initialzied the Unity player when the component is mounted. | ||
* Event invoked when the component is mounted. This sets the component | ||
* reference and starts the mounting of the UnityInstance. | ||
*/ | ||
Unity.prototype.componentDidMount = function () { | ||
this.unityContext.setComponentReference(this); | ||
this.mountUnityInstance(); | ||
}; | ||
/** | ||
* Event invoked when the component will unmount. This force quits the | ||
* UnityInstance which will clear it from the memory. | ||
*/ | ||
Unity.prototype.componentWillUnmount = function () { | ||
this.unityContext.quitUnityInstance(); | ||
}; | ||
/** | ||
* Initialized the Unity Loader and mounts the UnityInstance to the component. | ||
*/ | ||
Unity.prototype.mountUnityInstance = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _unityInstanceParamters, _unityInstance; | ||
var _unityInstanceParamters, _unityInstance, error_1; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
this.unityContext.setComponentReference(this); | ||
_a.trys.push([0, 3, , 4]); | ||
return [4 /*yield*/, this.unityLoaderService.load(this.unityContext.unityConfig.loaderUrl)]; | ||
@@ -118,3 +132,8 @@ case 1: | ||
this.unityContext.setUnityInstance(_unityInstance); | ||
return [2 /*return*/]; | ||
return [3 /*break*/, 4]; | ||
case 3: | ||
error_1 = _a.sent(); | ||
console.warn("Something went wrong while mouting the UnityInstance", error_1); | ||
return [3 /*break*/, 4]; | ||
case 4: return [2 /*return*/]; | ||
} | ||
@@ -125,11 +144,4 @@ }); | ||
/** | ||
* When the component will be unmounted, the UnityInstance will quit. | ||
*/ | ||
Unity.prototype.componentWillUnmount = function () { | ||
this.unityContext.quitUnityInstance(); | ||
}; | ||
/** | ||
* Renders the unity wrapper and player. | ||
* @returns {React.ReactNode} element | ||
* @public | ||
*/ | ||
@@ -136,0 +148,0 @@ Unity.prototype.render = function () { |
@@ -40,3 +40,3 @@ import "../declarations/window"; | ||
/** | ||
* Quits the Unity Instance and removes it from memory. | ||
* Quits the Unity Instance and clears it from memory. | ||
*/ | ||
@@ -43,0 +43,0 @@ quitUnityInstance(): void; |
@@ -37,3 +37,3 @@ "use strict"; | ||
/** | ||
* Quits the Unity Instance and removes it from memory. | ||
* Quits the Unity Instance and clears it from memory. | ||
*/ | ||
@@ -40,0 +40,0 @@ UnityContext.prototype.quitUnityInstance = function () { |
@@ -34,2 +34,3 @@ "use strict"; | ||
_this.unityLoaderScript.onload = function () { return resolve(); }; | ||
_this.unityLoaderScript.onerror = function () { return reject("Unable to load " + url); }; | ||
_this.documentHead.appendChild(_this.unityLoaderScript); | ||
@@ -36,0 +37,0 @@ }); |
{ | ||
"name": "react-unity-webgl", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"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.", | ||
@@ -24,4 +24,4 @@ "main": "./distribution/exports.js", | ||
"@types/react": "16.9.46", | ||
"typescript": "^4.0.2" | ||
"typescript": "4.0.2" | ||
} | ||
} |
@@ -16,3 +16,4 @@ <div align="center"> | ||
[**Documentation**](https://github.com/elraccoone/react-unity-webgl/wiki) · | ||
[**Test Environment**](https://github.com/jeffreylanters/react-unity-webgl-test) | ||
[**Test Environment**](https://github.com/jeffreylanters/react-unity-webgl-test) · | ||
[**Buy me a Coffee**](https://paypal.me/jeffreylanters) | ||
**≫** | ||
@@ -19,0 +20,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
81769
599
74