diff --git a/package.json b/package.json index 3544a40..e69bfef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-unity-renderer", - "version": "2020.0.2", + "version": "2020.0.3", "description": "React Unity Renderer allows to interactively embed Unity WebGL builds into a React powered project.", "main": "./dist/index.js", "types": "./dist/index.d.ts", diff --git a/src/components/UnityRenderer.ts b/src/components/UnityRenderer.ts index 86ef9dd..ddd97ff 100644 --- a/src/components/UnityRenderer.ts +++ b/src/components/UnityRenderer.ts @@ -135,8 +135,11 @@ export const UnityRenderer: VFC = ({ // on context change useEffect(() => { + // remove (previous) context if any + if (!context || context !== ctx) unmount(); + + // set new context if (context) setCtx(context); - else unmount(); }, [context]); // on mount