Skip to content

Commit 6fd7758

Browse files
Merge pull request #213 from jonasi/isao/more-cleanup
reverse order of setUnityInstance and quitUnityInstance
2 parents 3bc90fd + 1508715 commit 6fd7758

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

source/components/unity.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,16 @@ export class Unity extends PureComponent<IUnityProps, {}> {
112112
_unityInstanceParameters,
113113
this.onProgress.bind(this)
114114
);
115+
// Finally pass the instance back to the context object.
116+
this.unityContext.setUnityInstance(_unityInstance);
115117
// Since the creation of the Unity Instance is async, we'll check the
116118
// component's mount state right aftater instantiating. If the component
117119
// is no longer mounted, we'll quit the Unity instance right away.
120+
// This needs to occur after the setUnityInstance call because
121+
// quitUnityInstance requires the instance to be set.
118122
// HACK requires type cast to boolean due to await between comparisons.
119123
if ((this.isComponentMounted as boolean) === false)
120124
return this.unityContext.quitUnityInstance();
121-
// Finally pass the instance back to the context object.
122-
this.unityContext.setUnityInstance(_unityInstance);
123125
} catch (message) {
124126
this.unityContext.dispatchEventListener("error", message);
125127
console.error("A problem occurred while mounting", message);

0 commit comments

Comments
 (0)