From 1508715e02b224a976db5baf6499d6f72c5405d3 Mon Sep 17 00:00:00 2001 From: Isao Jonas Date: Sat, 24 Jul 2021 12:14:57 -0500 Subject: [PATCH] reverse order of setUnityInstance and quitUnityInstance quitUnityInstance relies on the unityInstace to be set --- source/components/unity.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/components/unity.ts b/source/components/unity.ts index 274e7ccc..780e0759 100644 --- a/source/components/unity.ts +++ b/source/components/unity.ts @@ -112,14 +112,16 @@ export class Unity extends PureComponent { _unityInstanceParameters, this.onProgress.bind(this) ); + // Finally pass the instance back to the context object. + this.unityContext.setUnityInstance(_unityInstance); // Since the creation of the Unity Instance is async, we'll check the // component's mount state right aftater instantiating. If the component // is no longer mounted, we'll quit the Unity instance right away. + // This needs to occur after the setUnityInstance call because + // quitUnityInstance requires the instance to be set. // HACK requires type cast to boolean due to await between comparisons. if ((this.isComponentMounted as boolean) === false) return this.unityContext.quitUnityInstance(); - // Finally pass the instance back to the context object. - this.unityContext.setUnityInstance(_unityInstance); } catch (message) { this.unityContext.dispatchEventListener("error", message); console.error("A problem occurred while mounting", message);