diff --git a/sim/api.ts b/sim/api.ts index a44cca6f..61c5a972 100644 --- a/sim/api.ts +++ b/sim/api.ts @@ -30,6 +30,13 @@ namespace pxsim.unity { //% blockId=helloUnity block="helloUnity" export function helloUnity() { + window.addEventListener('message', (event) => { + const command = event.data.unityCommand; + const data = event.data.unityData; + if (!!command) { + console.log(`Received command ${command} from unity with data: ${data}`); + } + }); if (!window.parent) { console.log('MakeCode: Parent not found'); } else {