From 4e95d0a8effab5429856b352508eefd5c96fac4d Mon Sep 17 00:00:00 2001 From: Varun Barad Date: Fri, 20 Dec 2024 15:19:53 +0530 Subject: [PATCH] Try to volley-ball. --- sim/api.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sim/api.ts b/sim/api.ts index c7fa9699..f53cde1f 100644 --- a/sim/api.ts +++ b/sim/api.ts @@ -26,6 +26,15 @@ namespace pxsim.hare { } } +let hasDefinedVolleyballReceiver = false; +const defineVolleyballReceiver = () => { + if (!hasDefinedVolleyballReceiver) { + window.parent.addEventListener('message', (event) => { + event.source.parent.parent.postMessage(event.data, '*'); + }); + } +}; + namespace pxsim.unity { //% blockId=helloUnity block="helloUnity" @@ -38,6 +47,7 @@ namespace pxsim.unity { console.log('MakeCode: Parent not found'); } else { console.log(`MakeCode: Parent found. It is: ${topLevelParent.document.title}`); + defineVolleyballReceiver(); topLevelParent.postMessage({ codeCommand: 'SEND_MIXPANEL_EVENT', codeData: {